Comparing commands

Rather than setting all commands when I change one command, I am looking at designing a system that fetches the commands already registered and compare the commands in the files then only update any new, changed or deleted commands. I have found the ApplicationCommand.equals() method, but this can not take a SlashCommandBuilder as the argument. Is there a way to convert the SlashCommandBuilder into an appropriate object or is there some other way to achieve this comparison? (I then hope to extend this to a hotload scenario that utilizes a file system watcher)
11 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
NyR
NyR8mo ago
Why can't you just pass all the commands? Any changed/deleted commands will just get updated on discord's side, you will be making same number of api call either way
The Fabulous Geek
The Fabulous GeekOP8mo ago
There is a hard limit on command creations each day.
NyR
NyR8mo ago
It won't matter tho, if you are only changing/adding one command, then only the command changed/added will be updated At least the unchanged commands don't count as command creation (unless im wrong, still making 200 requests a day is quite a limit to break easily)
The Fabulous Geek
The Fabulous GeekOP8mo ago
Just to be clear...are you refering to using the REST methods or the ApplicationCommandManager methods. And you are saying just send it all and anything new will be created, anything removed will be deleted, and anything updated will be updated. And the only limit will be new?
NyR
NyR8mo ago
Yes, and ApplicationCommandManager also uses REST internally
That means making a new command with an already-used name for your application will update the existing command. There is a global rate limit of 200 application command creates per day, per guild
The limit is only for command creates, so unless you create a new command everytime (and that exceeds 200 limit) you are fine
The Fabulous Geek
The Fabulous GeekOP8mo ago
I think what worries me is that the PUT API overwrite all commands, and I assuem the set() method of ApplicationCommandManger uses PUT. Ohh, I got it. Use the create() method, which will either create or update. THen for delete just have to determine that through program and call delete method
NyR
NyR8mo ago
^ like this says, it'll just update the command if it already exists
The Fabulous Geek
The Fabulous GeekOP8mo ago
Thank you much!
NyR
NyR8mo ago
Also
No description
The Fabulous Geek
The Fabulous GeekOP8mo ago
Ohh crap, I totaly missed that when I read it. Wow, perfect. Thank you!
Want results from more Discord servers?
Add your server