wip: work on new poll command

This commit is contained in:
2021-07-30 12:52:10 -04:00
parent 83672bba00
commit f9f93afcd1
6 changed files with 41 additions and 14 deletions

View File

@@ -3,8 +3,11 @@ import discord
import requests
import json
import requests
from datetime import date
from discord.ext import commands
OPTION_EMOJIS = ["1", "2", "3", "4", "5"]
class Fun(commands.Cog):
"""Commands that are good for the soul!"""
@@ -41,4 +44,25 @@ class Fun(commands.Cog):
github_embed.add_field(name="Open Issues", value=repo_info['open_issues'], inline=True)
github_embed.set_footer(text=f"Repo created at • {repo_info['created_at'].split('T')[0]}")
await ctx.send(embed=github_embed)
await ctx.send(embed=github_embed)
@commands.command(usage="\"<question>\" <options>")
async def poll(self, ctx, *params: str) -> None:
"""Creates a poll with the given parameters."""
if len(params) <= 1:
await ctx.send("**Please provide the parameters for the poll. ex.** `!poll \"My question?\" option1 option2`")
return
question = params[0]
options = params[1:]
# create embed response
poll_embed = discord.Embed(title=question, description="\u200b", color=0x3DCCDD)
for i in range(len(options)):
poll_embed.add_field(value="\u200b", name=f"{OPTION_EMOJIS[i]} {options[i]}", inline=False)
poll_embed.set_footer(text=f"Poll created on • {date.today().strftime('%m/%d/%y')}")
message = await ctx.send(embed=poll_embed)
for i in range(len(options)):
await message.add_reaction(OPTION_EMOJIS[i])