I want the the discord bot to pick a random message out of several options. And it kinda works: The bot picks a random message, but only by restarting the bot. Code:
const percent = ["0-10%" , "10-20%" , "20-30%" , "30-40%" , "40-50%" , "50-60%" , "60-70%" , "70-80%" , "80-90%" , "90-100%"]
const result = Math.floor(Math.random() * percent.length);
client.on("message", (message) => {
if(message.content.startsWith('.percent')){ var mentionedMember = message.mentions.members.first();
const wvg = new Discord.MessageEmbed()
.setColor('#ff4da6')
.addFields(
{ name: message.mentions.members.first().user.username
, value: "percent:" } ,
{ name: percent[result]
, value: "text" }
)
.setTimestamp()
.setFooter(message.author.username);
message.channel.send(wvg)
console.log(message.member.user.tag +' executed command .percent')
}
})
Would be nice if you could help me.
Aucun commentaire:
Enregistrer un commentaire