Slash commands not being created
I have multiple slash commands that wont be create for some reason, and I have no Idea how to fix it, heres my code that sets it up:
21 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 OPheres the rest of it:
there's nothing registering commands in any of that code
As in I cant just make the slash commands in the required files?
such as:
the .rules is a .js file in the code and it has all the slash commands inside it but its not setting it up?
it depends on what you mean by "setting it up"
like in the ./rules it has:
does that not set/register it already?
well that should show them in discord, assuming that's actually called somewhere
uh more explanation on the "called somewhere"?
you can place some logs to see if that's called
you need that code to be called somewhere
or well, to execute at all
node won't just read all your files and execute every .js it encounters
given you're using
client
there then I assume that's inside a function of some sort
that's being called by index, passing the client
^^I also worry that when you say this is in
./rules
, that means with the following, you're adding a ClientReady
listener when ClientReady
is emitted
yes I use it in a function such as:
with all the code between and at the end export it and import it into index.js
so what should I do about that?
if you're registering your ready event listener after it has been emitted then those listeners will never be triggered
because ready only triggers once
honestly I'd suggest reorganizing and consolidating all of your event listeners into 1 listener per event so that it's less confusing about what executes when
just don't listen to ready inside those setup functions
do your setup directly there
pretty sure that'll error the second boot though
since iirc application.commands.create throws an error if the command already exists
(it doesn't, it just edits the command)
ah, mb then
still, don't register commands in ready
it's more recommended to only register when your command's datas actually change
you can reach the daily command register limit if you keep doing it on ready
sorry back!
Hm so how should I rewrite the code, I am still pretty new to this
instead of multiple listeners per event, just have 1 per event
then delegate work from there
Hmm okay ty, I'll see if i can
I mean it's just removing the wrap on client.on()
just call your setups directly
don't make them listen to ready
okayy ty
thank you both, it made my code less messy but my commandds still dont get created
nvmm it worked
tysmm