so i want to let my bot choose from multiple messages when someone sends prefix random but everytime i test it it says "0" and i dont know why. This is what i have already.
client.on('message', message =>{
const member = message.guild.member
if(message.content === prefix 'random'){
message.channel.send('random1' | 'random2' | 'random3')
}
});
i also have tried doing "," instead of "|" but then it only sends random1
CodePudding user response:
If you want to send a random string, you cannot use OR
operator (which is ||
btw...).
You have to do something like:
const randomStrings = ['random1', 'random2', 'random3'];
const getRandomInt = (max) => Math.floor(Math.random() * max);
client.on('message', (message) => {
const member = message.guild.member;
if (message.content === prefix 'random') {
message.channel.send(randomStrings[getRandomInt(randomStrings.length)]);
}
});