(SOLVED) Issues With Slash Command Integration
I followed the tutorial in the documentation about creating slash commands, but I've run into a couple of issues.
1) When I run my bot I get the console message saying Successfully reloaded application (/) commands, but they don't work because my bot doesn't actually show as online despite me using
bot.login(MY TOKEN)
.
2) Uncommenting out the line that says commands.push(command.data.toJSON())
gives me the error depicted in the attached image.
According to npm, I am using version 14.3.0 of discord.js, and - as far as I can see - I have followed the tutorial exactly as shown on the website. I am using v18.7.0 of Node.
I'm a complete novice at JavaScript, so this is all very complicated for me; apologies in advance if it turns out I've made a screamingly obvious error that my tiny mind couldn't comprehend.
The code I'm using can be found on Pastebin at https://pastebin.com/pSM10ex6, and the code I am using for the slash command (the basic /ping) is at the bottom.
If you need any further details, please let me know.9 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I updated the code with that block, but now I keep getting this when trying to start the bot.
It shows as online, but the /ping command doesn't work.
I've updated the Pastebin with the new code.
I have no idea what that means.
(Reminder that I'm new to this.)
Got it working by looking at the code on GitHub. Thanks for the help.
Actually, there's something else. I'd like to have a single slash command that does different things depending on the channel it is used in.
Is this possible?
Yes
Use if, else if …
interaction.channel.id
Ah, right, that's what I was missing. Thanks.
Will give you the id of the channel the command was executed in
Or switch(interaction.channel.id) {}