Pretty much all in the title. I want my bot to respond with a random reply from a pool of replies. This is what I have so far:
const Discord = require('discord.js');
const bot = new Discord.Client();
bot.on('ready', () =>{
console.log('Just Chillin');
bot.user.setActivity('Working' , { type: 'BotOn'}).catch(console.error);
});
function randomMessage(){
var randomNumber = Math.round(Math.random()*2); // 0, 1 or 2
switch(randomNumber){
case 0: return 'Hello!';
case 1: return 'Hi!';
case 2: return 'Hola';
}
}
bot.on('message' , message => {
if(message.content.toLowerCase().includes('ping'))
message.reply('pong')
else if(message.content.toLowerCase().includes('Hello'))
message.reply(randomMessage());
});
Also, I do not have much experience in Java, only R, so I was also wondering where you would put the first chunk of code. Would you put it below or above the bot.on('message', message=>
? Also, when I have that code entered, nothing happens and everything else runs fine.
Thank you in advance. I apologize for my lack of Java knowledge.