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 toolkit•3y 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
SorNionOP•3y ago
treble/luna
treble/luna•3y 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
SorNionOP•3y ago
Is there a command to do that automatically?
treble/luna
treble/luna•3y ago
no
SorNion
SorNionOP•3y ago
What?
treble/luna
treble/luna•3y ago
show your command handler
SorNion
SorNionOP•3y ago
treble/luna
treble/luna•3y ago
well, the command you're trying to run is not being pushed into client.comandos
SorNion
SorNionOP•3y ago
If not? The folder where all the js are is loaded. And in that case, how do I load those commands?
SorNion
SorNionOP•3y ago
treble/luna
treble/luna•3y ago
also thats just your deploy file thats not your command handler
SorNion
SorNionOP•3y ago
treble/luna
treble/luna•3y ago
where is your interactionCreate event
SorNion
SorNionOP•3y ago
And how is it possible that it reads the slash command but then does not execute it?
SorNion
SorNionOP•3y ago
treble/luna
treble/luna•3y 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
SorNionOP•3y 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/luna•3y ago
did you write that code
SorNion
SorNionOP•3y ago
Only the functions
treble/luna
treble/luna•3y 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 docs•3y 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
SorNionOP•3y 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/luna•3y 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
SorNionOP•3y ago
If I modify the handlers, will I be able to start everything?
treble/luna
treble/luna•3y ago
yes
SorNion
SorNionOP•3y ago
Ok, I'll get to it, thank you very much for your help.
SorNion
SorNionOP•3y ago
SorNion
SorNionOP•3y ago
I make this But
SorNion
SorNionOP•3y ago
treble/luna
treble/luna•3y ago
define it basic js also
d.js docs
d.js docs•3y ago
guide Creating Your Bot: Command handling read more
treble/luna
treble/luna•3y ago
follow the guide the above code is invalid
SorNion
SorNionOP•3y ago
And this code?
Unknown User
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
entropy
entropy•3y ago
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.

Did you find this page helpful?