-3
const Discord = require('discord.js');
const bot = new Discord.Client();

bot.on('message', (message) => {
    if(message.content == 'ping') {
        message.reply('Pong');
    }
});

bot.login('my token is here');

I want my bot to say something when the user says something that contains 'server IP' I currently have this code, but it only replies when I send 'ping', how can I make it where it detects when the word 'ping' is in the sentence?

newbie
  • 1,551
  • 1
  • 11
  • 21
Ressii
  • 1
  • 2
  • 2
  • 4

1 Answers1

1

You can use .includes(...) to check if the content (returns a string) of a message contains 'ping'.

Like so:

if(message.content.includes('ping')) {
    message.reply('Pong');
}
newbie
  • 1,551
  • 1
  • 11
  • 21