The bot does not read the command although it does appear in the slash bar

Hello, I am creating commands for my bot, but I do not know what happens that although the code is 100% right, there is no error and even let me put the command and information, when sending the message tells me the bot that the command does not exist. I need someone to help me urgently please.
36 Replies
d.js toolkit
d.js toolkit15mo 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!
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
wherever you push your commands in presumably client.commands, you arent pushing that command also remove the packages that use outdated discord.js version and update
SorNion
SorNionOP15mo ago
Is there a command to do that automatically?
treble/luna
treble/luna15mo ago
no
SorNion
SorNionOP15mo ago
What?
treble/luna
treble/luna15mo ago
show your command handler
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
well, the command you're trying to run is not being pushed into client.comandos
SorNion
SorNionOP15mo ago
If not? The folder where all the js are is loaded. And in that case, how do I load those commands?
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
also thats just your deploy file thats not your command handler
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
where is your interactionCreate event
SorNion
SorNionOP15mo ago
And how is it possible that it reads the slash command but then does not execute it?
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
because you dont do it not in that part of the code well that expects your command to export a run function yours has an execute function which isnt even being reached as its not present in your client.commandos
SorNion
SorNionOP15mo ago
How do I fix that? I haven't been doing this for a long time and I don't really know much about it. Can each js be loaded one by one? By a list
treble/luna
treble/luna15mo ago
did you write that code
SorNion
SorNionOP15mo ago
Only the functions
treble/luna
treble/luna15mo ago
yeah so please take the time to familiarize yourself with js first djs requires a strong js understanding as for your issues, i listed above one more issue is that you call your function with 2 params, client and interaction but your actual command file only has one, named interaction, which will be your client
d.js docs
d.js docs15mo ago
The order of function parameters must match between definition and function call.
function execute(client, interaction) { ... };
execute(interaction, client);
function execute(client, interaction) { ... };
execute(interaction, client);
- mismatch! you pass an interaction where the client is expected - mismatch! you pass the client where an interaction is expected
SorNion
SorNionOP15mo ago
But I still don't understand why I can't read the js file of the command, in this case called "poll". With the interaction I should be able to start all of them.
treble/luna
treble/luna15mo ago
read what i said your command exports an execute function your command handler calls a run function and your command is only partially being pushed into your comandos namely just the data , not your execute function
SorNion
SorNionOP15mo ago
If I modify the handlers, will I be able to start everything?
treble/luna
treble/luna15mo ago
yes
SorNion
SorNionOP15mo ago
Ok, I'll get to it, thank you very much for your help.
SorNion
SorNionOP15mo ago
SorNion
SorNionOP15mo ago
I make this But
SorNion
SorNionOP15mo ago
treble/luna
treble/luna15mo ago
define it basic js also
d.js docs
d.js docs15mo ago
guide Creating Your Bot: Command handling read more
treble/luna
treble/luna15mo ago
follow the guide the above code is invalid
SorNion
SorNionOP15mo ago
And this code?
Unknown User
Unknown User15mo ago
Message Not Public
Sign In & Join Server To View
entropy
entropy15mo ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Want results from more Discord servers?
Add your server