Exemplo n.º 1
0
    async def create_poll(self, ctx, duration, *, title):
        """
        Allows a user to create a poll.
        """

        duration = await self.parse_time_as_delta(duration)

        if not duration:
            await ctx.send("Poll must have a valid duration "
                           "that is greater than zero")
            return

        end_date = ut.get_utc_time() + duration
        embed = await self.create_poll_embed(title, end_date, False)
        message = await ctx.send(embed=embed)

        # Adds control emojis
        for emoji in POLL_CONTROL_EMOJI:
            await message.add_reaction(emoji)

        # Deletes the original command message
        await ctx.message.delete()

        poll = Poll.create(title=title,
                           creator_id=ctx.author.id,
                           message_id=message.id,
                           channel_id=message.channel.id,
                           end_date=end_date)

        await self.update_response_counts(poll)