From 172fe83288fe4cca677e9f1bbb3f08c7fbd2a649 Mon Sep 17 00:00:00 2001 From: pacnpal <183241239+pacnpal@users.noreply.github.com> Date: Fri, 15 Nov 2024 14:30:50 +0000 Subject: [PATCH] Added a command existence check using discord.utils.get() Only register the command if it's not already present Maintained all other functionality including cog loading and task initialization --- birthday/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/birthday/__init__.py b/birthday/__init__.py index 32293a2..369be29 100644 --- a/birthday/__init__.py +++ b/birthday/__init__.py @@ -11,8 +11,9 @@ async def setup(bot: Red) -> None: try: cog = Birthday(bot) await bot.add_cog(cog) - # Add context menu command - bot.tree.add_command(birthday_context_menu) + # Add context menu command if it doesn't exist + if not discord.utils.get(bot.tree.get_commands(), name="Give Birthday Role"): + bot.tree.add_command(birthday_context_menu) # Initialize scheduled tasks try: await cog.reload_scheduled_tasks()