From 674c4263363f0bf1f8e44de93192bbab04363163 Mon Sep 17 00:00:00 2001 From: pacnpal Date: Sat, 28 Sep 2024 17:04:29 -0400 Subject: [PATCH] Removed dependency --- birthday-cog/README.md | 7 ++----- birthday-cog/birthday.py | 15 ++++++++------- birthday-cog/info.json | 14 ++++++++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/birthday-cog/README.md b/birthday-cog/README.md index 6326715..2264aa7 100644 --- a/birthday-cog/README.md +++ b/birthday-cog/README.md @@ -14,15 +14,12 @@ This cog for [Red-DiscordBot](https://github.com/Cog-Creators/Red-DiscordBot) al To install this cog, follow these steps: 1. Ensure you have Red-DiscordBot V3 installed. -2. Install the required dependencies: ``` - [p]pip install pytz - ``` -3. Add the repository to your bot: +2. Add the repository to your bot: ``` [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 ``` diff --git a/birthday-cog/birthday.py b/birthday-cog/birthday.py index 68c541c..a86f204 100644 --- a/birthday-cog/birthday.py +++ b/birthday-cog/birthday.py @@ -3,7 +3,6 @@ from redbot.core import commands, checks from redbot.core.bot import Red from redbot.core.config import Config from datetime import datetime, time, timedelta -import pytz class Birthday(commands.Cog): """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.") # Schedule role removal - pacific_tz = pytz.timezone('US/Pacific') - now = datetime.now(pacific_tz) - midnight = pacific_tz.localize(datetime.combine(now.date() + timedelta(days=1), time.min)) - + utc_now = datetime.utcnow() + pacific_offset = timedelta(hours=-8) # Pacific Standard Time offset + 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: 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): """Remove the birthday role at the specified time.""" @@ -91,4 +92,4 @@ class Birthday(commands.Cog): del self.birthday_tasks[guild.id] async def setup(bot): - await bot.add_cog(Birthday(bot)) + await bot.add_cog(Birthday(bot)) \ No newline at end of file diff --git a/birthday-cog/info.json b/birthday-cog/info.json index c15919d..c68323e 100644 --- a/birthday-cog/info.json +++ b/birthday-cog/info.json @@ -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`.", "name": "Birthday", "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.", - "tags": ["birthday", "role", "temporary"], - "requirements": ["pytz"], + "tags": [ + "birthday", + "role", + "temporary" + ], + "requirements": [], "min_bot_version": "3.5.0", "max_bot_version": "3.9.9", "type": "COG" -} +} \ No newline at end of file