Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a bot react to its own message?

So I am trying to make the bot react to it's own message, for a polls feature of my discord server, and I am wondering how to make the bot add reactions to it's message? (Currently, it adds the reaction to the person who executed the .suggestion command.)

client.on('message', message => {
  if (message.content.startsWith('.suggestion')) {

        const channel = message.guild.channels.find('name', 'polls');
        const args = message.content.slice(12).trim().split(/ +/g);
        let suggestion = args.slice(0).join(" ");
        if (!channel) return;

        let embed = new Discord.RichEmbed()
        .setColor("#55FFFF")
        .setDescription('▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n▬▬▬▬▬▬▬▬▬**«    Vexil Player Suggestion    »**▬▬▬▬▬▬▬▬▬▬\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n\n**Suggested By »** ' + message.author + '\n\n**Suggestion »** ' + suggestion + '\n\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬\n▬▬▬▬▬▬▬▬▬▬▬▬**«**     @everyone     **»**▬▬▬▬▬▬▬▬▬▬▬▬\n▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬')
        .setFooter('Vexil', client.user.avatarURL)

    channel.send(embed);
    message.react("👍")
    message.react("👎");

  }
});

Thank you in advanced for your help and time. <3

like image 599
Askingg Avatar asked Jul 06 '18 22:07

Askingg


People also ask

How do I get discord bot to react to messages?

To react with an emoji, you need to use the message. react() method. Once you have the emoji character, all you need to do is copy & paste it as a string inside the . react() method!

How do I send a message with reactions on discord?

React to a Message in Discord on Desktop Then, in the message's top-right corner, click the “Add Reaction” (emoji) icon. Discord will open an emoji picker allowing you to choose an emoji for your message reaction. Here, click any emoji you like. Your selected emoji will be added to your message as a reaction.


2 Answers

You can react directly after the message is sent by using .then()

channel.send(embed).then(sentEmbed => {
    sentEmbed.react("👍")
    sentEmbed.react("👎")
})
like image 51
Nik Avatar answered Sep 18 '22 17:09

Nik


It's easy!

channel.send(embedName).then(sentMessage => {
  const emoji = message.guild.find('name', 'emojiName');
  sentMessage.react(emoji);
});
like image 21
asciidude Avatar answered Sep 18 '22 17:09

asciidude