#!/bin/env python3

import discord
from discord.ext import commands

class Poll:
    def __init__(self, bot):
        self.bot = bot
        self.emoji_map = ['1\U000020e3', '2\U000020e3', '3\U000020e3', '4\U000020e3', 
                          '5\U000020e3', '6\U000020e3', '7\U000020e3', '8\U000020e3', 
                          '9\U000020e3']

    @commands.command(aliases=['survey'])
    async def poll(self, ctx, poll_name: str, timeout: float, *, poll_options: str):
        """ Create a poll for the channel to vote on 

        Usage:
        .poll 'A quoted name' 60 comma, delimited, options """ 

        if timeout > (21600):
            return await ctx.send('Please choose a timeout time which is less than 6 hours.')

        option_list = poll_options.split(',')

        if len(option_list) < 2:
            return await ctx.send('You need at least 2 options to call it a poll, jeez.')
        elif len(option_list) > len(self.emoji_map):
            return await ctx.send("That's too many options ")

        if len(poll_name) > 256:
            return await ctx.send('Sorry, titles must be under 256 characters per Discord limits.')

        # Do a heckin good embed
        em = discord.Embed(title=poll_name, color=discord.Color.teal())
        em.set_footer(text=f'Poll created by {ctx.author}', icon_url=ctx.author.avatar_url)

        description_list = []
        for idx, opt in enumerate(option_list):
            description_list.append(f'{self.emoji_map[idx]} {opt}')

        em.description = '\n'.join(description_list)

        poll_msg = await ctx.send(embed=em)


def setup(bot):
    bot.add_cog(Poll(bot))

@@ -12,17 +12,16 @@
 python3%0A
-%0A
 import d
@@ -27,16 +27,46 @@
 discord%0A
+from datetime import datetime%0A
 from dis
@@ -1302,19 +1302,19 @@
 set_
-footer(text
+author(name
 =f'P
@@ -1374,16 +1374,95 @@
 tar_url)
+%0A        em.set_footer('Poll created at')%0A        em.timestamp = datetime.now()
 %0A%0A      
@@ -1656,16 +1656,16 @@
 _list)%0A%0A
-
         
@@ -1701,16 +1701,112 @@
 ed=em)%0A%0A
+        for e in self.emoji_map%5B:len(option_list)%5D:%0A            await poll_msg.add_reaction(e)%0A%0A
 %0Adef set

add reactions