Slash command
I have been having an issue with making slash commands work for a while. I have been able to register the commands, but I can't make the application respond.
Here is my index.js file.
Here is interactionCreate.js file
Here is one of my commands -> ping2.js
Here is my current terminal log
Please find the correct files using the uploaded txt attachments below after this post.
55 Replies
sorry it is interactionCreate, typo in txt
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
in which file do i do that?
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
oh, rightπ€¦ββοΈ
Console
client is still undefined
Really?
Yes
And you probably want to pass the interaction to the command as well.
As Qjuh, said, use interaction.client
yes. no
now there is no error message, but nothing happened
Just -> The application did not respond
You need to reply to the command
console.log(command)
output
command?
Probably best if you read this: https://discordjs.guide/creating-your-bot/command-handling.html#reading-command-files
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
my collection is called commands
Yes, but that collection will be empty if you haven't added anything to it
how do i add stuff on to it
By reading the guide I sent you
i have
and most of my code is copied from that guide
for command handling
then console.log the collection to see
k
return
So it is empty
I might have missed it, but I don't see you filling the collection anywhere. Also, it's bad practice to deploy slash commands on every start
YAYAYYAAYAYAYAYAYAYAYAYAYAYAYAY. my ping2 command works
But not my othersπ
how do i use the embedBuilder
Documentation suggestion for @PAdventures: EmbedBuilder
Represents a embed in a message (image/video preview, rich embed, etc.)
so
works?
Looks good
this doesnt work though
What's the error?
Footer takes in an object, you're using a string
i gtg for a few
?
You're using a
string
in .setFooter()
, whereas you need to be using an objectso
.setFooter(Created by PAdventures)
?No, like
{ text: 'footer' }
.setFooter{ text: 'Created by PAdventures'}?
The object goes inside the footer
k
i need to go and ill be back in like 10-20mins
Because you named it
message
, but then call interaction.reply()
. Please learn some basic JShow do i fix
Rename the variable
I don't understand why you pass so many things to execute(), but only use one of them.
You can also import all 3 imports in one line. No need to have 2 lines of require("discord.js")
k
thanks
And, in earlier code you sent, you only actually pass
interaction
, so your code thinks client
in your help command is an interaction
.beacuase i was using message originally
I see
right
k
Error
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
i dont see anything wrong
oh wait
nvm
looking at wrong area lol
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View
when i add await an error shows ->
SyntaxError: await is only valid in async functions and the top level bodies of modules
Unknown Userβ’3y ago
Message Not Public
Sign In & Join Server To View