Handling deletion of all guild specific slash commands with BulkOverwrite
I've been using BulkOverwrite to manage slash commands for guilds and use the
ApplicationCommandRegistryRegisterOptions
to specify an array of guildIds
to create guild specific commands with registerChatInputCommand
. This works great as long as I have at least one guild specific command for a guild.
The issue is when II remove a guild id from all the command ApplicationCommandRegistryRegisterOptions
then it won't overwrite anything in that guild and so it doesn't delete the removed commands.
Below I've included an example of two commands. Assume that previously both commands were registered for guilds ['111','222','333'] specifically. If I make an update to remove guild '222' from the Help Command and guild '333' from both the Ping and Help Command, then guild '222' will properly delete the Help Command, however guild '333' will not be updated and keep both the Help and Ping Command.
What is the recommended approach to remove guild specific commands from '333' after an update like this? and can it be done using Sapphire and BulkOverwrite somehow?
Solution:Jump to solution
Sapphire doesnt handle deletion of commands, not with bulk nor anything else. You'll have to use the DiscordJS methodologies for that.
Alternatively you can use https://slash-commands-gui.androz2091.fr/settings...
Slash Commands GUI
Graphical User Interface to explore and edit your bot's slash commands!
5 Replies
Solution
Sapphire doesnt handle deletion of commands, not with bulk nor anything else. You'll have to use the DiscordJS methodologies for that.
Alternatively you can use https://slash-commands-gui.androz2091.fr/settings
Slash Commands GUI
Graphical User Interface to explore and edit your bot's slash commands!
Thanks @Favna , I don't think it's quite accurate to say
Sapphire doesnt handle deletion of commands
since it does delete both global application and guild specific commands when using BulkOverwrite which I've seen from my usage and this is also stated here. https://github.com/sapphiredev/framework/blob/465b05c/src/lib/types/Enums.ts#L55
The part I'm trying to solve is when an update makes it so a guild is no longer registered via guildIds, which as it says here is not covered by BulkOverwrite.
the same applies for guild commands, but only for guilds that are registered in the registry via guildIds
I'll look into using discordjs as you recommend though. Thanks for the update.GitHub
framework/Enums.ts at 465b05c935a994ff8fbf980eab15a8155077ac14 · sa...
Discord bot framework built on top of discord.js for advanced and amazing bots. - framework/Enums.ts at 465b05c935a994ff8fbf980eab15a8155077ac14 · sapphiredev/framework
Sapphire doesn't delete the commands when using bulk overwrite. It calls the discord API endpoint that simply overrides their data. Sapphire doesn't make any DELETE calls.
So yes it is correct.
https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
(Also it's a bit silly to argue such things with a creator of any library, it's safe to assume the creator(s) always know what happens the best)
Discord Developer Portal
Discord Developer Portal — API Docs for Bots and Developers
Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with.
Thank you again for correcting me. I only meant to say that I notice that commands can be removed by Sapphire which was due my misunderstanding of your statement being specifically about
deletion
vs overriding
which seems can have the result of removing a command without explicitly calling delete. It's not my intention to argue anything, just trying to clarify my own understanding and I really appreciate the time you take answer questions and help me and others better utilize the Sapphire framework.The thing ultimately is that we use the provided guildIds to know for which guilds we need to call bulk overwrite (as that's a per guild thing) so when you remove a guild, we no longer call bulk overwrite for that.
Alternative to djs way what you could do is make your own fetch to the endpoint in question through something like a GitHub actions workflow wherein you parse an input of an id