Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. poll_emojis = {0: ':zero:', 1: ':one:', 2: ':two:', 3: ':three:', 4: ':four:'}
  2.  
  3. @client.event
  4. async def on_message(message):
  5. if message.author == client.user:
  6. return
  7.  
  8. if message.content.startswith('$create_poll'):
  9.  
  10. poll_content = message.content.split('"')
  11. poll_text = poll_content[1]
  12. poll_options = []
  13. poll_option_text = ''
  14. count = 0
  15. for poll_option in poll_content[2:]:
  16. if poll_option.strip() != '':
  17. poll_options.append(poll_option)
  18. poll_option_text += '{0}: {1}t'.format(poll_emojis[count], poll_option)
  19. count += 1
  20.  
  21. posted_message = await message.channel.send('**{0}**n{1}'.format(poll_text, poll_option_text))
  22.  
  23. count = 0
  24. for poll_option in poll_options:
  25. await posted_message.add_reaction(Emoji(poll_emojis[count]))
  26. count += 1
  27.  
  28. {react.emoji: react.count for react in message.reactions}
  29.  
  30. @bot.command()
  31. async def poll(ctx, *, text):
  32. message = await ctx.send(text)
  33. for emoji in ('👍', '👎'):
  34. await message.add_reaction(emoji)
  35.  
  36. @bot.command()
  37. async def create_poll(ctx, text, *emojis: discord.Emoji):
  38. msg = await ctx.send(text)
  39. for emoji in emojis:
  40. await msg.add_reaction(emoji)
  41.  
  42. !create_poll "Vote in the Primary!" :obamaemoji: :hillaryemoji:
  43.  
  44. @bot.command()
  45. async def create_poll(ctx, emojis: Greedy[Emoji], *, text):
  46. msg = await ctx.send(text)
  47. for emoji in emojis:
  48. await msg.add_reaction(emoji)
  49.  
  50. !create_poll :obamaemoji: :hillaryemoji: Vote in the Primary!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement