Reputation: 19
I'm trying to convert the message content to lower case and reply with an array element.
I have the following code, but when I use it, the bot comes online but doesn't reply. Are there any obvious errors in this snippet?
client.once('ready', () => {
console.log('Ready!');
});
client.on('message', message => {
var i = Math.floor(55*Math.random());
if (message.content.toLowerCase().message.content.includes('message') || message.content.toLowerCase().message.content.includes('msg')) {
message.channel.startTyping();
delay(3500).then(function() {
message.channel.send(`'${quote[i]}'`);
message.channel.stopTyping();
});
}
})
Upvotes: 0
Views: 5676
Reputation: 35540
message.content.toLowerCase().message.content.includes('message')
message.content
is a string, so message.content.toLowerCase()
is also a string. That means that you should not have .toLowerCase().message.content.includes("message")
but instead just have .toLowerCase().includes("message")
.
Upvotes: 2