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 (
  13.     [emojiCharacters[1], emojiCharacters[2], emojiCharacters[3]].includes(
  14.       reaction.emoji.name
  15.     ) && user.id === message.author.id
  16.   )
  17. } // so reage se apenas for usados emojis certos e a pessoa que enviou a primeira mensagem
  18.  
  19. prompt
  20.   .awaitReactions(filter3, {
  21.     // funcçao que permite enviar emotes e depois verificar qual emote foi escolhido
  22.     max: 1,
  23.     time: 60000,
  24.     errors: ['time']
  25.   })
  26.   .then(async collected => {
  27.     const reaction = collected.first()
  28.  
  29.     switch (reaction.emoji.name) {
  30.       case emojiCharacters[1]:
  31.         console.log('number=1')
  32.         message.reply('You choose 1')
  33.         total = total + 1
  34.         break
  35.       case emojiCharacters[2]:
  36.         console.log('number=2')
  37.         message.reply('You choose 2')
  38.         total = total + 2
  39.         break
  40.       case emojiCharacters[3]:
  41.         console.log('number=3')
  42.         message.reply('You choose 3')
  43.         total = total + 3
  44.         break
  45.     }
  46.     return total
  47.   })
  48.   .catch(collected => {
  49.     console.log(`After a minute, only ${collected.size} out of 4 reacted.`)
  50.     message.reply(
  51.       'TIME OUT ⏰\nYou didnt picked a number, you just lost\nTry again later'
  52.     )
  53.   })
  54.  
  55. react(prompt)
  56.  
  57. 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