Home > Net >  (Discord Bot) I was wondering how I could make the code process all of the messages as lower case
(Discord Bot) I was wondering how I could make the code process all of the messages as lower case

Time:01-02

i wanted to make it process every message as lowercase so that it would respond if someone said
Tim Nagle, Tim nagle, tim Nagle, etc.

client.on('message', (message) => {
    if(message.content.includes('tim nagle')) {
        message.reply('hello');
}});

CodePudding user response:

You could overwrite the current messages being sent:

client.on('message', (message)=>{
  message.content = message.content?.toLowerCase();
})

Now all the message contents will be lowercased. The question mark checks if there is a message, therefore will avoid errors where you are trying to lowercase undefined.

CodePudding user response:

The problem I had was where to place toLowerCase() I had also forgotten the parenthesis at the end

client.on('message', (message) => {
    if(message.content.toLowerCase().includes('tim nagle')) {
        message.reply('I want this twink ***OBLITERATED***');
}});
  • Related