Slash commands don't disappearing (nextcord)

Question:

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.

Asked By: hellyet

||

Answers:

You should try kicking your bot and then inviting it back to your server. If this doesn’t work, regenerate your bot’s token. This should sync it back with Discord, and the command should be gone.

Answered By: MrHDumpty

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)
Answered By: hellyet
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.