Summary
Application command names must be unique raised when calling sync_commands() method
Reproduction Steps
When I unload/load/reload a cogs using bot.unload_extension(), etc. I also call the bot.sync_commands() method as unloading the extension doesn't unload the commands from discord.
Minimal Reproducible Code
@bridge.bridge_command(hidden=True)
@commands.is_owner()
async def unload(self, ctx: commands.Context, extension: str):
extension = extension.lower()
path = None
if extension in self._iterdir_names(self.bot.cogs_path):
path = self.cogs_folder
elif extension in self._iterdir_names(self.bot.extensions_path):
path = self.bot.extensions_path.name
if path is not None:
print(f"Unloading {path}.{extension}")
self.bot.unload_extension(f"{path}.{extension}")
print(f"Unloaded {path}.{extension}")
await ctx.reply(f"Unloaded {path}.{extension}", delete_after=3)
else:
logging.warning(
f"{extension} doesn't exist in the cogs or extensions folder."
)
await self.bot.sync_commands()
Expected Results
The sync command to update the bot's commands on the discord api to match those of the bots.
Actual Results
File "C:\Users\<user>\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 126, in wrapped
ret = await coro(arg)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\commands\core.py", line 856, in _invoke
await self.callback(self.cog, ctx, **kwargs)
File "E:\Docs\discord bot\cogs\basehelpercommands.py", line 43, in load
else:
File "C:\Users\<user>\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 629, in sync_commands
registered_commands = await self.register_commands(
File "C:\Users\<user>\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\bot.py", line 529, in register_commands
registered = await register("bulk", data, _log=False)
File "C:\Users\<user>\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\http.py", line 359, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 12: Application command names must be unique
Intents
intents = discord.Intents.default() intents.message_content = True
System Information
- Python v3.9.7-final
- py-cord v2.0.0-candidate
- py-cord pkg_resources: v2.0.0rc1
- aiohttp v3.7.4.post0
- system info: Windows 10 10.0.19043
Checklist
Additional Context
No response
Summary
Application command names must be unique raised when calling sync_commands() method
Reproduction Steps
When I unload/load/reload a cogs using bot.unload_extension(), etc. I also call the bot.sync_commands() method as unloading the extension doesn't unload the commands from discord.
Minimal Reproducible Code
Expected Results
The sync command to update the bot's commands on the discord api to match those of the bots.
Actual Results
Intents
intents = discord.Intents.default() intents.message_content = True
System Information
Checklist
Additional Context
No response