From 4edb139a465c3762dea1b4ad6ff54fc5c42e2d5e 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] 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()