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
This commit is contained in:
pacnpal
2024-11-15 14:30:50 +00:00
parent 23fac11cfd
commit 172fe83288

View File

@@ -11,7 +11,8 @@ async def setup(bot: Red) -> None:
try: try:
cog = Birthday(bot) cog = Birthday(bot)
await bot.add_cog(cog) await bot.add_cog(cog)
# Add context menu command # 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) bot.tree.add_command(birthday_context_menu)
# Initialize scheduled tasks # Initialize scheduled tasks
try: try: