Reputation: 91
I am coding a bot on discord called LowerBot, it is made in javascript and is using npm and discord.js. If somebody can pinpoint exactly where my bot went wrong that would be nice.
Here is my code:
function getAfterSpace(str) {
return str.split(' ')[1]; // get after space
}
client.on("message", msg => {
if (msg.content.toLowerCase().includes === ";say ") {
msg.channel.send(`${getAfterSpace(msg.content)}`)
}
})
Upvotes: 0
Views: 56
Reputation: 1
There are many ways to do it, but this is what I would do:
if(message.content.toLowerCase.StartsWith(";say") {
let result = message.content.split(" "); // creates an array of each word
result = result.slice(1); // removes first entry (";say");
result = result.join(" "); // combines each object in the array into a string. each object is separated by a space.
}
Upvotes: 0
Reputation: 17532
Because includes
is a method and you are comparing against the method actual method and not an invocation of it.
It should be msg.content.toLowerCase().includes(";say ")
instead.
Upvotes: 2