From d6911c96820df6362968a122ed16443be245cc80 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:26:08 -0400 Subject: [PATCH 1/3] updated birthday.py --- birthday/birthday.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/birthday/birthday.py b/birthday/birthday.py index f2b16dd..c546638 100644 --- a/birthday/birthday.py +++ b/birthday/birthday.py @@ -122,6 +122,31 @@ class Birthday(commands.Cog): await self.schedule_birthday_role_removal(ctx.guild, member, birthday_role, midnight) + @commands.command() + async def bdaycheck(self, ctx): + """Check the upcoming birthday role removal tasks.""" + # Check if the user has permission to use this command + allowed_roles = await self.config.guild(ctx.guild).allowed_roles() + if not any(role.id in allowed_roles for role in ctx.author.roles): + return await ctx.send("You don't have permission to use this command.") + + scheduled_tasks = await self.config.guild(ctx.guild).scheduled_tasks() + if not scheduled_tasks: + return await ctx.send("There are no scheduled tasks.") + + message = "Upcoming birthday role removal tasks:\n" + for member_id, task_info in scheduled_tasks.items(): + member = ctx.guild.get_member(int(member_id)) + if not member: + continue + role = ctx.guild.get_role(task_info["role_id"]) + if not role: + continue + remove_at = datetime.fromisoformat(task_info["remove_at"]).replace(tzinfo=ZoneInfo(await self.config.guild(ctx.guild).timezone())) + message += f"- {member.display_name} ({member.id}): {role.name} will be removed at {remove_at}\n" + + await ctx.send(message) + async def schedule_birthday_role_removal(self, guild, member, role, when): """Schedule the removal of the birthday role.""" await self.config.guild(guild).scheduled_tasks.set_raw(str(member.id), value={ @@ -158,4 +183,4 @@ class Birthday(commands.Cog): async def setup(bot): cog = Birthday(bot) await bot.add_cog(cog) - await cog.reload_scheduled_tasks() \ No newline at end of file + await cog.reload_scheduled_tasks() From a5d8b384dd98e9dd46934f478a38a07cc70bee3d Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:28:28 -0400 Subject: [PATCH 2/3] generated uuid for identifier --- birthday/birthday.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/birthday/birthday.py b/birthday/birthday.py index c546638..25e147c 100644 --- a/birthday/birthday.py +++ b/birthday/birthday.py @@ -11,7 +11,7 @@ class Birthday(commands.Cog): def __init__(self, bot: Red): self.bot = bot - self.config = Config.get_conf(self, identifier=1234567890) + self.config = Config.get_conf(self, identifier=428eb4b6-de7f-45ba-8eda-a15c163f1c7d) default_guild = { "birthday_role": None, "allowed_roles": [], From 63191bc17008670c7bd94749235bb6aceb7ec034 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Sun, 29 Sep 2024 00:32:20 -0400 Subject: [PATCH 3/3] fixed uuid --- birthday/birthday.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/birthday/birthday.py b/birthday/birthday.py index 25e147c..ca23a1a 100644 --- a/birthday/birthday.py +++ b/birthday/birthday.py @@ -11,7 +11,7 @@ class Birthday(commands.Cog): def __init__(self, bot: Red): self.bot = bot - self.config = Config.get_conf(self, identifier=428eb4b6-de7f-45ba-8eda-a15c163f1c7d) + self.config = Config.get_conf(self, identifier=5458102289) default_guild = { "birthday_role": None, "allowed_roles": [],