Dupliacte commands

When registering commands with Sapphire, it created duplicate ones on top of the old ones from legacy codebase. How can I delete duplicate ones so only the currently active (Sapphire generated ones) remain? Deleting all commands and re-registering them is also an option I can do, just not sure how
25 Replies
Favna
Favna2d ago
Use the DiscordJS methods for managing commands (client.application.commands is the store) or use a webapp such as https://slash-commands-gui.androz2091.fr Alternatively switch to Bulk Overwrite mode so every command is always overwritten
Slash Commands GUI
Graphical User Interface to explore and edit your bot's slash commands!
Ved
VedOP2d ago
Where do I set bulk overwrite mode?
Ved
VedOP2d ago
Thank you! @Boomeravna I'm not sure if bulk overwrite resolved my issue, I still see all the old commands and duplicate ones even after restarting Discord client
Ved
VedOP2d ago
No description
Ved
VedOP2d ago
Log:
ApplicationCommandRegistries(BulkOverwrite) Successfully overwrote global application commands. The application now has 4 global commands
ApplicationCommandRegistries(BulkOverwrite) Successfully overwrote global application commands. The application now has 4 global commands
Favna
Favna2d ago
Do they also show when typing a / instead of going through the integrations menu? anyway you can use the website I linked to verify
Ved
VedOP2d ago
Yes I don't feel confident putting in client secret to a website, sorry
Favna
Favna2d ago
first of all, you can reset it afterwards. Secondly, it's an open source project so you can verify the code yourself: https://github.com/Androz2091/slash-commands-gui
GitHub
GitHub - Androz2091/slash-commands-gui: GUI tool to explore Slash C...
GUI tool to explore Slash Commands of your bot, built on Vue 3 and TailwindCSS 🚀 - Androz2091/slash-commands-gui
Favna
Favna2d ago
but if you still dont want to, then use the aforementioned discordjs methods
Favna
Favna2d ago
never forget that Sapphire is a framework on top of DiscordJS, ergo anything that's possible with DiscordJS is possible with Sapphire. And for DiscordJS there is https://discordjs.guide/
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Ved
VedOP2d ago
No description
Ved
VedOP2d ago
It should be only 4 commands, and it's missing one of them on that list
Favna
Favna2d ago
that is very weird. Could it be that some are guild specific commands and others are global commands? because this should not be possible at all with bulk overwrite and the logs clearly say it was successfully overwritten
Ved
VedOP2d ago
Not sure, I didn't work on the project before. How can I flush them all?
Favna
Favna2d ago
what exactly do you mean "i didnt work on the project before"? Are you adopting someone else's code?
Ved
VedOP2d ago
Yes, I have the old code, but it's an outdated hot mess that I'm rewriting and reworking the functionality
Favna
Favna2d ago
Hmmm
Ved
VedOP2d ago
Anyways, I just want to cleanup all those commands and have them re-register
Favna
Favna2d ago
See I would say you can use the discordjs store to unregister the commands But if the code is messy then they might just re-register right afterwards You can try it I suppose
Ved
VedOP2d ago
Old code is no longer used, only new one based on Sapphire It's why I want to cleanup
Favna
Favna2d ago
It's a Collection so you can loop through it like any djs Collection to get all the ids and then call delete https://discord.js.org/docs/packages/discord.js/14.17.3/ApplicationCommandManager:Class
discord.js
discord.js
discord.js is a powerful Node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.
Favna
Favna2d ago
Oh and there's https://discord.js.org/docs/packages/discord.js/14.17.3/GuildApplicationCommandManager:Classfor guild specific commands. For this you'll need a double loop, outer loop for each guild, inner loop for the command ids
Ved
VedOP2d ago
Great, I'll look into it. Thanks for help!
Favna
Favna2d ago
Hopefully it'll solve the issue because I'm a bit stumped on it otherwise as it's quite weird If it doesn't it might be easiest for me to receive the code so I can look through what you're running now

Did you find this page helpful?