jeudi 7 janvier 2021

How to send a discord.js random embed?

I'm looking for a code that would let me send an random embed that I created when someone types a command. For the moment with the code that I have, all embeds are being sent but I want the bot to only send a random one, not all 4. Is this possible ?

module.exports = class PizzaTest extends BaseCommand {
  constructor() {
    super('pizzatest', 'fun', []);
  }

  async run(client, message, args) {
      const capreseEmbed = new Discord.MessageEmbed()
      .setTitle('• Attention, pizza en livraison!  🚀')
      .setDescription(`<@${message.author.id}>, il semblerait que ta commande soit prĂȘte. Tu viens de recevoir une magnique pizza **Caprese** ! \n\n *Les ingrĂ©dients sont: Mozarella, Olives, Tomates SĂ©chĂ©es & Basilic.*`)
      .setThumbnail('https://i.imgur.com/McSXASC.png')
      .setFooter(message.author.username, message.author.displayAvatarURL())
      .setTimestamp()
      .setColor("#baff58");

      const reineEmbed = new Discord.MessageEmbed()
      .setTitle('• Attention, pizza en livraison!  🚀')
      .setDescription(`<@${message.author.id}>, il semblerait que ta commande soit prĂȘte. Tu viens de recevoir une magnique pizza **Reine** ! \n\n *Les ingrĂ©dients sont: Mozarella, Jambon, Champignons & Basilic.*`)
      .setThumbnail('https://i.imgur.com/AKStODY.png')
      .setFooter(message.author.username, message.author.displayAvatarURL())
      .setTimestamp()
      .setColor("#baff58");

      const vegeEmbed = new Discord.MessageEmbed()
      .setTitle('• Attention, pizza en livraison!  🚀')
      .setDescription(`<@${message.author.id}>, il semblerait que ta commande soit prĂȘte. Tu viens de recevoir une magnique pizza **VĂ©gĂ©tarienne** ! \n\n *Les ingrĂ©dients sont: Mozarella, Olives, Poivrons, Champignons & Basilic.*`)
      .setThumbnail('https://i.imgur.com/U0qrSk9.png')
      .setFooter(message.author.username, message.author.displayAvatarURL())
      .setTimestamp()
      .setColor("#baff58");

      const andalouseEmbed = new Discord.MessageEmbed()
      .setTitle('• Attention, pizza en livraison!  🚀')
      .setDescription(`<@${message.author.id}>, il semblerait que ta commande soit prĂȘte. Tu viens de recevoir une magnique pizza **Andalouse** ! \n\n *Les ingrĂ©dients sont: Mozarella, Poivrons, Boulette de Boeuf & Sauce Andalouse.*`)
      .setThumbnail('https://i.imgur.com/dvgkC4K.png')
      .setFooter(message.author.username, message.author.displayAvatarURL())
      .setTimestamp()
      .setColor("#baff58");


  message.channel.send(capreseEmbed).catch(err => console.log(err));
  message.channel.send(reineEmbed).catch(err => console.log(err));
  message.channel.send(vegeEmbed).catch(err => console.log(err));
  message.channel.send(andalouseEmbed).catch(err => console.log(err));
  }
}

I know that I can use something like .setDescription(description) with all of them stated at the beginning but I need the description and thumbnail to match so that wouldn't work I guess ?

Thank you!




Aucun commentaire:

Enregistrer un commentaire