mirror of
https://github.com/pacnpal/Pac-cogs.git
synced 2025-12-20 10:51:05 -05:00
Removed dependency
This commit is contained in:
@@ -14,15 +14,12 @@ This cog for [Red-DiscordBot](https://github.com/Cog-Creators/Red-DiscordBot) al
|
|||||||
To install this cog, follow these steps:
|
To install this cog, follow these steps:
|
||||||
|
|
||||||
1. Ensure you have Red-DiscordBot V3 installed.
|
1. Ensure you have Red-DiscordBot V3 installed.
|
||||||
2. Install the required dependencies:
|
|
||||||
```
|
```
|
||||||
[p]pip install pytz
|
2. Add the repository to your bot:
|
||||||
```
|
|
||||||
3. Add the repository to your bot:
|
|
||||||
```
|
```
|
||||||
[p]repo add birthday-cog https://github.com/yourusername/birthday-cog
|
[p]repo add birthday-cog https://github.com/yourusername/birthday-cog
|
||||||
```
|
```
|
||||||
4. Install the cog:
|
3. Install the cog:
|
||||||
```
|
```
|
||||||
[p]cog install birthday-cog birthday
|
[p]cog install birthday-cog birthday
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ from redbot.core import commands, checks
|
|||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.config import Config
|
from redbot.core.config import Config
|
||||||
from datetime import datetime, time, timedelta
|
from datetime import datetime, time, timedelta
|
||||||
import pytz
|
|
||||||
|
|
||||||
class Birthday(commands.Cog):
|
class Birthday(commands.Cog):
|
||||||
"""A cog to assign a birthday role until midnight Pacific Time."""
|
"""A cog to assign a birthday role until midnight Pacific Time."""
|
||||||
@@ -71,14 +70,16 @@ class Birthday(commands.Cog):
|
|||||||
await ctx.send(f"🎉 Happy Birthday, {member.mention}! You've been given the {birthday_role.name} role until midnight Pacific Time.")
|
await ctx.send(f"🎉 Happy Birthday, {member.mention}! You've been given the {birthday_role.name} role until midnight Pacific Time.")
|
||||||
|
|
||||||
# Schedule role removal
|
# Schedule role removal
|
||||||
pacific_tz = pytz.timezone('US/Pacific')
|
utc_now = datetime.utcnow()
|
||||||
now = datetime.now(pacific_tz)
|
pacific_offset = timedelta(hours=-8) # Pacific Standard Time offset
|
||||||
midnight = pacific_tz.localize(datetime.combine(now.date() + timedelta(days=1), time.min))
|
pacific_now = utc_now + pacific_offset
|
||||||
|
pacific_midnight = datetime.combine(pacific_now.date() + timedelta(days=1), time.min)
|
||||||
|
utc_midnight = pacific_midnight - pacific_offset
|
||||||
|
|
||||||
if ctx.guild.id in self.birthday_tasks:
|
if ctx.guild.id in self.birthday_tasks:
|
||||||
self.birthday_tasks[ctx.guild.id].cancel()
|
self.birthday_tasks[ctx.guild.id].cancel()
|
||||||
|
|
||||||
self.birthday_tasks[ctx.guild.id] = self.bot.loop.create_task(self.remove_birthday_role(ctx.guild, member, birthday_role, midnight))
|
self.birthday_tasks[ctx.guild.id] = self.bot.loop.create_task(self.remove_birthday_role(ctx.guild, member, birthday_role, utc_midnight))
|
||||||
|
|
||||||
async def remove_birthday_role(self, guild, member, role, when):
|
async def remove_birthday_role(self, guild, member, role, when):
|
||||||
"""Remove the birthday role at the specified time."""
|
"""Remove the birthday role at the specified time."""
|
||||||
@@ -91,4 +92,4 @@ class Birthday(commands.Cog):
|
|||||||
del self.birthday_tasks[guild.id]
|
del self.birthday_tasks[guild.id]
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
await bot.add_cog(Birthday(bot))
|
await bot.add_cog(Birthday(bot))
|
||||||
@@ -1,12 +1,18 @@
|
|||||||
{
|
{
|
||||||
"author": ["PacNPal"],
|
"author": [
|
||||||
|
"Your Name"
|
||||||
|
],
|
||||||
"install_msg": "Thank you for installing the Birthday cog! Make sure to set up the birthday role and allowed roles using `[p]birthdayset`.",
|
"install_msg": "Thank you for installing the Birthday cog! Make sure to set up the birthday role and allowed roles using `[p]birthdayset`.",
|
||||||
"name": "Birthday",
|
"name": "Birthday",
|
||||||
"short": "Assign a birthday role until midnight Pacific Time",
|
"short": "Assign a birthday role until midnight Pacific Time",
|
||||||
"description": "This cog allows you to assign a special birthday role to users that automatically expires at midnight Pacific Time. It includes features to restrict usage to specific roles and ignore role hierarchy.",
|
"description": "This cog allows you to assign a special birthday role to users that automatically expires at midnight Pacific Time. It includes features to restrict usage to specific roles and ignore role hierarchy.",
|
||||||
"tags": ["birthday", "role", "temporary"],
|
"tags": [
|
||||||
"requirements": ["pytz"],
|
"birthday",
|
||||||
|
"role",
|
||||||
|
"temporary"
|
||||||
|
],
|
||||||
|
"requirements": [],
|
||||||
"min_bot_version": "3.5.0",
|
"min_bot_version": "3.5.0",
|
||||||
"max_bot_version": "3.9.9",
|
"max_bot_version": "3.9.9",
|
||||||
"type": "COG"
|
"type": "COG"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user