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

@@ -0,0 +1,3 @@
from cogs.finance import Finance
from cogs.fun import Fun
from cogs.programming import Programming

View File

@@ -1,5 +1,4 @@
import os
from typing import List
import requests
import json
from discord.ext import commands
@@ -8,8 +7,8 @@ class Finance(commands.Cog):
"""Commands to query stock and crypto prices."""
@commands.command(usage="<tickers>")
async def stock(self, ctx, *tickers: List[str]) -> None:
"""Get prices for the given stock tickers. Will default tickers to AAPL, GOOG, MSFT and AMZN if none provided."""
async def stock(self, ctx, *tickers: str) -> None:
"""Gets prices for the given stock tickers. Will default tickers to AAPL, GOOG, MSFT and AMZN if none provided."""
ALPHAVANTAGE_API_KEY = os.getenv('ALPHAVANTAGE_API_KEY')
# default tickers
@@ -42,8 +41,8 @@ class Finance(commands.Cog):
await ctx.send(msg_response)
@commands.command(usage="<tickers>")
async def crypto(self, ctx, *tickers: List[str]) -> None:
"""Get prices for the given crypto tickers. Will default tickers to BTC, ETH and LTC if none provided."""
async def crypto(self, ctx, *tickers: str) -> None:
"""Gets prices for the given crypto tickers. Will default tickers to BTC, ETH and LTC if none provided."""
LUNAR_CRUSH_API_KEY = os.getenv("LUNAR_CRUSH_API_KEY")
# default tickers

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])

View File

@@ -1,9 +1,9 @@
from discord.ext import commands
class Python(commands.Cog):
"""Commands about python programming."""
class Programming(commands.Cog):
"""Commands about programming."""
@commands.command()
async def resources(self, ctx) -> None:
"""Will provide resources for python programming."""
"""Will provide resources for programming."""
await ctx.send("Some resources for you here!") # TODO: Add resources