izy521 / discord.io

A small, single-file library for creating DiscordApp clients from Node.js or the browser
https://discord.gg/0MvHMfHcTKVVmIGP
MIT License
535 stars 155 forks source link

Adding reaction to bot message #284

Closed dgz9 closed 6 years ago

dgz9 commented 6 years ago

I'm not seeing much documentation about adding reactions. Is there a way to add 2 reactions to a bot message?

Peacerekam commented 6 years ago

through usage of callbacks and addReaction method, reactions are ratelimited so it would be best to check for that, but a rule of thumb is 500ms between them.

let reactions = ['⬅', '➡', '❌']

bot.sendMessage({
  to: channelID,
  message: "hello world"
}, function (err,res){
  for (let i = 0; i < reactions.length; i++){
    setTimeout(() => {
      bot.addReaction({
        channelID: channelID,
        messageID: res.id,
        reaction: reactions[i]
      })
    }, i * 500);
  }
})

obraz

dgz9 commented 6 years ago

That clears it up. Thanks a lot!