How to clean up duplicate commands? #7884
Replies: 3 comments 4 replies
-
You're supposed to re-sync the guild with an empty set of commands. However, I forgot to write |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
EDIT: This worked. But the suggestion by @Rapptz would also work. Just make sure to run Unedited original post: I think this is actually something weird lingering from my previous use of SlashCommand(
bot,
debug_guild=debug_guild,
sync_commands=True,
delete_from_unused_guilds=True,
) And that seems to have cleaned up all the "broken" application commands. It was the inclusion of if delete_from_unused_guilds:
self.logger.info("Deleting unused guild commands...")
other_guilds = [
guild.id for guild in self._discord.guilds if guild.id not in cmds["guild"]
]
# This is an extremly bad way to do this, because slash cmds can be in guilds the bot isn't in
# But it's the only way until discord makes an endpoint to request all the guild with cmds registered.
for guild in other_guilds:
with suppress(discord.Forbidden):
existing = await self.req.get_all_commands(guild_id=guild)
if len(existing) != 0:
self.logger.debug(f"Deleting commands from {guild}")
await self.req.put_slash_commands(slash_commands=[], guild_id=guild) 🤷🏻♀️ Thanks for the help! Sorry to bother you with what I think is honestly a bug from another library. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For every one of my commands I see two options for it when I start typing. For example:

One of these commands will work. The other one will cause an error:
Here's the code for this
/about
command:Here's how I am syncing commands:
Note that I am not automatically syncing commands in my
setup_hook()
function as I've seen the FAQ against doing that many, many times.I AM using a debug guild currently but in the past I have also synced globally (many weeks ago).
Note that previous to migrating to discord.py 2.0 I had been using discord-interactions v3.x with code like this:
Beta Was this translation helpful? Give feedback.
All reactions