"Started refreshing 0 application (/) commands."
Hello! I'm having trouble with a really stubborn issue in my code and I'm honestly pretty stumped. I have a minimal, but decent understanding of JS, and I'm using a command handler based on the official DJS guide + a DJS v14 tutorial that I've modified to suit the needs of my bot. My console doesn't log any errors, but despite there being a 'ping.js' command in a subfolder of the 'cmds' folder, it doesn't seem to recognize the file as an application command. I logged the file paths in the console and it's reading them just fine, but it still isn't registering 'ping.js' as a command file.
I'll post my command handler and console log in a follow-up message.
5 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!This is my command handler code:
And this is what my console logs (as you can see, it includes the file paths that I mentioned before, so I know it's reading them alright):
Additionally, I've searched this server for answers related to the title of this post, and none of them have gotten me any further.
const data = await rest.put( Routes.applicationCommands(clientId, cmds) );routes doesn't take two arguments, it only takes one, the client id; check how the guide puts commands and replicate that. (your second argument, cmds, should actually be the second argument of rest.put, but read below)
cmds.set(cmd.data.name, cmd);it seems like cmds is a collection (or a map) and you're trying to post that same cmds variable. rest doesn't take a map as an argument so that'd fail, it takes an array of command data instead (inside an object), either save the data in a separate array or pass the values of the collection, check the guide as well for that
:method: Collection#values()
Returns an iterable of values in the map
:mdn: Array.from()
The Array.from() static method creates a new, shallow-copied Array instance from an iterable or array-like object.
Understood, I’ll try those edits and see if that fixes it. Thanks so much! :)