mardi 7 juillet 2020

discord.js make exception for message author

I have this code which chooses a random user and displays their name and what they won, the problem is it can also make the user who sent the giveaway message the winner and the same with bots. How can I make an exception for the msg.author?

if(msg.content.startsWith('-giveaway'))
    {
      const suggestion = msg.content.slice(10);
      const user = msg.guild.members.random();
      let embed = new Discord.RichEmbed()
        .setTitle('Prize : ' + suggestion)
        .addField('Host : ', msg.author)
        .addField('Nyertes : ', user)
        .setFooter('Verzió 1.1')
        .setTimestamp()
        msg.channel.send(embed);
        console.log(`${user.user}`).catch(console.error);
    }



Aucun commentaire:

Enregistrer un commentaire