Search code examples
pythondiscordnextcord

Slash commands don't disappearing (nextcord)


I'm developing a discord bot using nextcord. When i'm registering slash command and deleting it later, it's also staying at discord command list.

What can I do to delete non-existent slash commands or sync actual bot's command list with discord? P.S. All of my commands are in different cogs

I was waiting about 4 hours for registering and sync slash commands by discord but to no avail.


Solution

  • The solution is adding all servers in default_guild_ids variable

    Use methods on_ready and on_guild_join

    Example code:

    class Bot(nextcord.ext.commands.Bot):
        async def on_ready(self):
            for guild in self.guilds:
                self.default_guild_ids.append(guild.id)
    
        async def on_guild_join(self, guild: nextcord.Guild):
            self.default_guild_ids.append(guild.id)