diff options
author | 2020-03-09 16:37:20 +1000 | |
---|---|---|
committer | 2020-03-09 16:37:20 +1000 | |
commit | 4ffdb13172251e77c727cd64ce7b18da0844e966 (patch) | |
tree | ce22bdd176dba332f751c7daf80a1d8d80f543e6 | |
parent | Merge pull request #823 from python-discord/tag-search-searches-tags-via-cont... (diff) |
Implement vote command.
The vote command takes a given list of options and generates a simple
message and corresponding reactions for each so members can quickly take
a vote on a subject during in-server discussions and meetings.
-rw-r--r-- | bot/cogs/utils.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py index 8ea972145..c5eaa547b 100644 --- a/bot/cogs/utils.py +++ b/bot/cogs/utils.py @@ -257,6 +257,24 @@ class Utils(Cog): embed.description = best_match await ctx.send(embed=embed) + @command(aliases=("poll",)) + @with_role(*MODERATION_ROLES) + async def vote(self, ctx: Context, title: str, *options: str) -> None: + """ + Build a quick voting poll with matching reactions with the provided options. + + A maximum of 20 options can be provided, as Discord supports a max of 20 + reactions on a single message. + """ + if len(options) > 20: + raise BadArgument("I can only handle 20 options!") + + options = {chr(i): f"{chr(i)} - {v}" for i, v in enumerate(options, start=127462)} + embed = Embed(title=title, description="\n".join(options.values())) + message = await ctx.send(embed=embed) + for reaction in options: + await message.add_reaction(reaction) + def setup(bot: Bot) -> None: """Load the Utils cog.""" |