Search code examples
pythondiscorddiscord.py

How to Remove old Slash Commands from a Discord Bot?


I recently used a Mee6 Premium Bot for my Discord server, but now I want to run my own bot with new slash commands (running on the Bot that was the Mee6 Bot). However, the old slash commands from Mee6 are still registered in my bot. When I type "/", all of my commands show up along with the commands from Mee6. How can I get rid of the Mee6 commands? I tried using my sync command to delete the old commands, but it didn't work. Here's my code:

@commands.command()
async def sync(self, ctx) -> None:
    fmt = await ctx.bot.tree.sync()
    await ctx.send(f"{len(fmt)} commands synced.")

def on_ready(self):
    cmdgroup= groupCommands(
        name="demo", description="This is just a Demo")
    self.bot.tree.add_command(cmdgroup)

Can someone please help me fix my sync command or suggest a solution to remove the Mee6 commands?

Just using an other Bot isn't an option since the Bot is already in some other servers

Just to clarify, with Mee6 Premium, you can use your own bot as the Mee6 bot. So the bot that I am currently using was previously running as the Mee6 bot.


Solution

  • It looks like you created the old commands as unique commands for your guild (not global commands). To remove them, you'll need to sync the tree by specifying your guild:

    # this will update the client commands which are only from your guild
    await ctx.bot.tree.sync(guild=ctx.guild)
    

    You only need to run this once.