Automatically delete a old slash command that has been renamed?

How would I achieve this, I am using sapphire 3.1.3, and I want it to automatically delete the old one when it detects a change.
Solution:
A PR has been created that will add this as a feature
Jump to solution
18 Replies
Favna
Favna2y ago
Sapphire currently doesn't have a feature to automatically delete slash commands. You can use the DJS methods for now. In the future we'll add a feature where we would use the Build Overwrite endpoint of the API meaning on every boot all your commands get wiped and reset - with the caveat that idHints will lose its use case when that is configured.
yusof
yusofOP2y ago
is it possible to make a listener of sort
Favna
Favna2y ago
in the ready listener you could check which commands are in the Command store and which you can find through the DJS application commands methods, diff those lists and remove any that are not in the Commands store
yusof
yusofOP2y ago
yeah thats what im doing rn would this line of code work client.application?.commands.cache.forEach((command: ApplicationCommand) => {command.delete()})
Favna
Favna2y ago
I actually have absolutely no idea lol sorry
yusof
yusofOP2y ago
im testing it rn lets see
Favna
Favna2y ago
client.application?.commands.set([]) I think this works too at least the docs say it does
yusof
yusofOP2y ago
client.application?.commands.set([]);
Favna
Favna2y ago
but you cannot use that in the ready listener because you'll delete everything sapphire just registered ofr you you need to diff the lists
yusof
yusofOP2y ago
how would I list the commands then
yusof
yusofOP2y ago
excuse me where did container come from oh wait nvm
Favna
Favna2y ago
Sapphire Framework
Using and extending container | Sapphire
The container is a way in which Sapphire achieves Dependency Injection. This is a very useful feature, since it
yusof
yusofOP2y ago
?
Favna
Favna2y ago
it's not a promise I'm not going to spoonfeed you code fyi. I gave you the directions to go for, you're on your own from there on.
Krish
Krish2y ago
I suggest making a script file to delete all of the slash commands at once (or just give the IDs) with rest api and rust that file wheneber you want to reset the commands.
yusof
yusofOP2y ago
yeah I cant figure this out I never even told you to spoonfeed me so ok
Solution
Favna
Favna2y ago
A PR has been created that will add this as a feature
Want results from more Discord servers?
Add your server