Well we will need to see the rest of the event you have this code in. I assume you have this code inside of a listener. Something like the following…
client.on('message', (receivedMessage) => {
if (receivedMessage.author == client.user) { // Prevent bot from responding to its own messages
return
}
if (receivedMessage.content.startsWith("!")) {
// Ok we have a message (that started with a "!" character) signaling a command.
// Here we would split off the first word (the one with the "!") and set your "command" variable to it
}
})
So with this code above you see that we are listening to messages in the channel. We first check to make sure it is not from the bot itself and secondly we look for the message to start with “!” (you can set this to whatever command character you would like to use). Once we know the message is an apparent command, we can split the message into its specific command and compare that with “testembed”. From there you should be pretty good to continue.
So basically, I use a command handler where I have a main file and for every command I want to add, I create a separate file- so, I have a file called “testembed.js” for the testembed command. Under my main file, I have something similar to what you outlined:
Then, in my separate testembed.js file, I have all the code which I showed in the main post.
(Note: I’ve used other more simple commands using the above layout, so I don’t believe the issue is in my main file- I think it’s in my testembed.js file. I could very well be wrong though.)
Ok well you define command in the listener, but I would hypothesize that you are not passing command on to the testembed.js file. I see you pass message, args and Discord. I believe this is setup assuming that testembed knows it is the command testbed, so it doesn’t need to check “command” anymore. Command is defined here in the message callback, but never passed on to the other file.