SHARE
TWEET

Untitled

a guest Jun 19th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var total = 0
  2. const prompt = await message.channel.send('Choose your number') // evia mensagem e da lhe o nome
  3.  
  4. const react = message => {
  5.   message
  6.     .react(emojiCharacters[1]) // vai reagir com emoji de 1 a 3
  7.     .then(() => message.react(emojiCharacters[2]))
  8.     .then(() => message.react(emojiCharacters[3]))
  9. } // reaçao do emoji de 1 a 3
  10.  
  11. const filter3 = (reaction, user) => {
  12.   return [emojiCharacters[1], emojiCharacters[2], emojiCharacters[3]].includes(reaction.emoji.name) && user.id === message.author.id
  13. } // so reage se apenas for usados emojis certos e a pessoa que enviou a primeira mensagem
  14.  
  15. prompt
  16.   .awaitReactions(filter3, {
  17.     // funcçao que permite enviar emotes e depois verificar qual emote foi escolhido
  18.     max: 1,
  19.     time: 60000,
  20.     errors: ['time']
  21.   })
  22.   .then(async collected => {
  23.     const reaction = collected.first()
  24.  
  25.     switch (reaction.emoji.name) {
  26.       case emojiCharacters[1]:
  27.         console.log('number=1')
  28.         message.reply('You choose 1')
  29.         total = total + 1
  30.         break
  31.       case emojiCharacters[2]:
  32.         console.log('number=2')
  33.         message.reply('You choose 2')
  34.         total = total + 2
  35.         break
  36.       case emojiCharacters[3]:
  37.         console.log('number=3')
  38.         message.reply('You choose 3')
  39.         total = total + 3
  40.         break
  41.     }
  42.     return total
  43.   })
  44.   .catch(collected => {
  45.     console.log(`After a minute, only ${collected.size} out of 4 reacted.`)
  46.     message.reply('TIME OUT ⏰\nYou didnt picked a number, you just lost\nTry again later')
  47.   })
  48.  
  49. react(prompt)
  50.  
  51. await message.channel.send(`O total é ${total}`)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top