CiY3
CiY3

Reputation: 135

reacting to message just created

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?

Upvotes: 0

Views: 125

Answers (2)

Omen
Omen

Reputation: 41

Here you go!:

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

Upvotes: 0

Elitezen
Elitezen

Reputation: 6710

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(...);

Upvotes: 2

Related Questions