aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Eivind Teig <[email protected]>2020-03-09 09:04:25 +0100
committerGravatar GitHub <[email protected]>2020-03-09 09:04:25 +0100
commit190ff0fd2422459674320fa0e096921e38872f2d (patch)
treea1bec4fe6eccf2d832cc532cd2fdc3443cdc9824
parentMerge pull request #824 from python-discord/antimalware-fix (diff)
parentDisambiguate codepoint value. (diff)
Merge pull request #826 from python-discord/vote
Implement vote command.
-rw-r--r--bot/cogs/utils.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bot/cogs/utils.py b/bot/cogs/utils.py
index 8ea972145..024141d62 100644
--- a/bot/cogs/utils.py
+++ b/bot/cogs/utils.py
@@ -257,6 +257,27 @@ 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) < 2:
+ raise BadArgument("Please provide at least 2 options.")
+ if len(options) > 20:
+ raise BadArgument("I can only handle 20 options!")
+
+ codepoint_start = 127462 # represents "regional_indicator_a" unicode value
+ options = {chr(i): f"{chr(i)} - {v}" for i, v in enumerate(options, start=codepoint_start)}
+ 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."""