m0nde
m0nde

Reputation: 19

discord bot using node.js - how do i convert a message to lowercase?

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

Answers (2)

Marc
Marc

Reputation: 1896

message.channel.send(`'${quote[i]}'.toLowerCase()`);

Upvotes: 0

Aplet123
Aplet123

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

Related Questions