Home > Net >  reacting to message just created
reacting to message just created

Time:02-12

I want to make the bot react to it's own message. I am making a !vote command and it can make a message saying "Cast your vote: " already. I want to make a reaction to that new message, like an example, where it reacts with a checkmark and a red x for people to click on. How can I do this?

CodePudding user response:

Sending a message returns a promise with said message. Resolve it and react to it.

message.channel.send(...)
    .then(msg => msg.react(...));

// or

const newMsg = await message.channel.send(...);
newMsg.react(...);

CodePudding user response:

Here you go!:

client.on("messageCreate", msg => {
  if (msg.content === `!vote`) {
    msg.channel.send(`Cast your vote:`).then(msg => {
      msg.react("✅");
      msg.react("❎");
    })
  }
});

CodePudding user response:

await <Message>.react('UNICODE_EMOJI');

https://discord.js.org/#/docs/discord.js/stable/class/Message?scrollTo=react

  • Related