Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- poll_emojis = {0: ':zero:', 1: ':one:', 2: ':two:', 3: ':three:', 4: ':four:'}
- @client.event
- async def on_message(message):
- if message.author == client.user:
- return
- if message.content.startswith('$create_poll'):
- poll_content = message.content.split('"')
- poll_text = poll_content[1]
- poll_options = []
- poll_option_text = ''
- count = 0
- for poll_option in poll_content[2:]:
- if poll_option.strip() != '':
- poll_options.append(poll_option)
- poll_option_text += '{0}: {1}t'.format(poll_emojis[count], poll_option)
- count += 1
- posted_message = await message.channel.send('**{0}**n{1}'.format(poll_text, poll_option_text))
- count = 0
- for poll_option in poll_options:
- await posted_message.add_reaction(Emoji(poll_emojis[count]))
- count += 1
- {react.emoji: react.count for react in message.reactions}
- @bot.command()
- async def poll(ctx, *, text):
- message = await ctx.send(text)
- for emoji in ('👍', '👎'):
- await message.add_reaction(emoji)
- @bot.command()
- async def create_poll(ctx, text, *emojis: discord.Emoji):
- msg = await ctx.send(text)
- for emoji in emojis:
- await msg.add_reaction(emoji)
- !create_poll "Vote in the Primary!" :obamaemoji: :hillaryemoji:
- @bot.command()
- async def create_poll(ctx, emojis: Greedy[Emoji], *, text):
- msg = await ctx.send(text)
- for emoji in emojis:
- await msg.add_reaction(emoji)
- !create_poll :obamaemoji: :hillaryemoji: Vote in the Primary!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement