disnake icon indicating copy to clipboard operation
disnake copied to clipboard

Another blind spot of command sync algorithm

Open EQUENOS opened this issue 2 years ago • 0 comments

Summary

Unloading app commands with guild_ids which were not specified anywhere else doesn't delete those commands.

Reproduction Steps

  • Register an app command X with exclusive guild_ids (by exclusive I mean that those guild_ids are not associated with other commands; by registering I mean adding a command and applying the sync algo)
  • Remove the app command X and resync

Minimal Reproducible Code

import disnake
from disnake.ext import commands


class Misc(commands.Cog):
    @commands.slash_command(guild_ids=[859404768992165920])
    async def example(self, inter: disnake.AppCmdInter) -> None:
        ...


bot = commands.InteractionBot(command_sync_flags=commands.CommandSyncFlags.all())
bot.add_cog(Misc())


@bot.event
async def on_ready():
    bot.remove_cog("Misc")
    print("Bot is ready. You can check the list of commands")


bot.run("BOT_TOKEN")

Expected Results

Command X should be gone

Actual Results

The command stays in the list of commands

Intents

disnake.Intents.default()

System Information

- Python v3.8.6-final
- disnake v2.9.0
    - disnake importlib.metadata: v2.4.0  
- aiohttp v3.8.1
- system info: Windows 10 10.0.19041 AMD64

Checklist

  • [X] I have searched the open issues for duplicates.
  • [X] I have shown the entire traceback, if possible.
  • [X] I have removed my token from display, if visible.

Additional Context

Probably the best solution is to compare ConnectionState._guild_application_commands to the list of invokable slash commands and remove any commands that are included in the first dict but are missing in the second.

EQUENOS avatar Sep 18 '23 15:09 EQUENOS