Cannot register commands globally
I am trying to register my slash commands to every server that my bot is in, but for some reason I can't. This code worked before it suddenly decided not working. I don't get any errors, it just halts the execution like it is still waiting for the response. My bot is in only two servers at the moment, I have tried kicking it from both of them and inviting back with application.commands and bot permissions. I have also tried using client.application.commands.set() instead of rest.put().
Here is a part of my code:
Also, if there is a better way to clear the application commands from every guild before adding the new ones, please let me know.
7 Replies
- 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!Routes.applicationCommands()
is the route you would use for global commands
it just halts the execution like it is still waiting for the responsethat sounds like a rate limit, which given the fact that you're making several unnecessary api calls prior to your commented code, this seems probable - deploying guild commands to each guild individually is not the same as deploying global commands - it's not necessary to clear commands by deploying an empty array before deploying commands bulk overwriting commands (with a
PUT
request) already removes any command that isn't in the array you deployed
- this also means that it's not necessary to clear each guild's guild commands by deploying empty arrays to eachThe reason I am deploying an empty array was because I had duplicates of every command previously, so I wanted to clear everything in every guild before deploying. Maybe clearing global application commands is not needed though.
that sounds like a rate limit, which given the fact that you're making several unnecessary api calls prior to your commented code, this seems probableEven when I delete the unnecessary api calls, Routes.applicationCommands() still doesn't work. Routes.applicationGuildCommands() (which I am using for a single guild) works with or without the unnecessary api calls. Not sure if the problem is rate limit
The reason I am deploying an empty array was because I had duplicates of every command previously, so I wanted to clear everything in every guild before deploying. Maybe clearing global application commands is not needed though.this would be if you had both global and guild commands of the same commands clearing them is something you would only need to do once and only for the type that you won't be using (guild commands in this case)
Even when I delete the unnecessary api calls, Routes.applicationCommands() still doesn't work. Routes.applicationGuildCommands() (which I am using for a single guild) works with or without the unnecessary api calls. Not sure if the problem is rate limitreturning to execution hanging, care to share your updated code? and on which line does it hang? is it that you've confirmed it hangs because
Successfully refreshed ${data.length} application commands!
doesn't log?The code that works:
The code that doesn't work:
and on which line does it hang? is it that you've confirmed it hangs because Successfully refreshed ${data.length} application commands! doesn't log?Yes, it hangs right where I wait for rest.put(Routes.applicationGuildCommands(...)) Ah that's probably the issue, you are right. I wasn't aware of this limit. One question tho. Does refreshing an already existing command count towards this limit, or do only newly registered commands count? If everything counts, I guess I need check if a command already exists in the application commands, then register if it doesn't. Right?
Updating an existing command does not count towards the command creation limit. Deleting and recreating is what would've caused this
Okay, thatβs good to know. Thank you both for all the help