How to register commands using .set() ( ill explain in thread )
hello
11 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!
- ✅
Marked as resolved by OPok so in my command handler i used to do a for loop with a client.commands.create(), but that made alot of ghost commands after a while. I changed it to a for loop with a array.push() for the slash commands and then client.commands.set(). but i cant get it to register the contextmenu commands. i do push them to the array aswell
Hi,
here's how i'm doing it :
separate files for each commands :
this.commands
is a Collection()
And then in the ClientReady event :
This is part of a wider class ofc but this should help you
Note that it's under dev, you might want to omit the for looping over guildIds (which is a whitelist for me)
And use client.application.commands.set(commands)
@Cyph Erzz thanks, i made my own version, kinda. altough the contextmenus wont load
Ah !
I'v never worked with contextMenu sorry can't help for now !
context menu commands are still application commands, so they're deployed exactly the same as slash commands
it's still recommended to separate your deployment from your bot running, as it's unnecessary to deploy commands if you haven't changed them
our guide's example deployment uses the REST client instead since it also doesn't require a logged in client
however, if you specifically want to use
<Client>.application.commands.set()
, that's totally up to you
that being said, it doesn't look like you're actually calling this anywhere
<Client>.commands
isn't a native property and is presumably a Collection
this is often used to store commands for your bot to actually handle interactions for, but setting commands in this collection doesn't send them to discordhi, thanks for the answer. im getting help in #djs-help-v14 altough we cant seem to see why it doesnt want to work
in future please don't crosspost
this was posted way before i started to ask in that channel.
yes, and asking in that channel was the crossposting
cuz i didnt see it because of discord
sorry bout that