From eaed08168c13cf7286672ac72e973f27bf838eda Mon Sep 17 00:00:00 2001 From: Stijn De Clercq Date: Sat, 5 Feb 2022 14:33:11 +0100 Subject: [PATCH] Inspire slash command, defer jpl table --- .gitignore | 1 + cogs/oneliners.py | 2 +- cogs/slash/football_slash.py | 1 + cogs/slash/other_slash.py | 23 +++++++++++++++++++++++ files/help.json | 2 +- 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 cogs/slash/other_slash.py diff --git a/.gitignore b/.gitignore index 9b3c80f..02e269f 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ files/ufora_notifications.json __pycache__ .env /venv/ +.pytest_cache \ No newline at end of file diff --git a/cogs/oneliners.py b/cogs/oneliners.py index 20bc822..358a822 100644 --- a/cogs/oneliners.py +++ b/cogs/oneliners.py @@ -151,7 +151,7 @@ class Oneliners(commands.Cog): @commands.command(name="Inspire") @help.Category(Category.Other) async def inspire(self, ctx): - image = get("http://inspirobot.me/api?generate=true") + image = get("https://inspirobot.me/api?generate=true") if image.status_code == 200: await ctx.send(image.text) diff --git a/cogs/slash/football_slash.py b/cogs/slash/football_slash.py index d10ba31..0f75eee 100644 --- a/cogs/slash/football_slash.py +++ b/cogs/slash/football_slash.py @@ -23,6 +23,7 @@ class FootballSlash(commands.Cog): @_jpl_group.command(name="table", description="Huidige rangschikking") async def _jpl_table_slash(self, ctx: ApplicationContext): + await ctx.response.defer() await ctx.respond(get_table()) @_jpl_group.command(name="update", description="Update de code voor deze competitie (owner-only)", default_permission=False) diff --git a/cogs/slash/other_slash.py b/cogs/slash/other_slash.py new file mode 100644 index 0000000..39350c7 --- /dev/null +++ b/cogs/slash/other_slash.py @@ -0,0 +1,23 @@ +from discord.ext import commands +from discord.commands import slash_command, ApplicationContext +from requests import get + +from startup.didier import Didier + + +class OtherSlash(commands.Cog): + def __init__(self, client: Didier): + self.client: Didier = client + + @slash_command(name="inspire", description="Genereer quotes via Inspirobot.") + async def _inspire_slash(self, ctx: ApplicationContext): + image = get("https://inspirobot.me/api?generate=true") + + if image.status_code == 200: + await ctx.respond(image.text) + else: + await ctx.respond("Uh oh API down.") + + +def setup(client: Didier): + client.add_cog(OtherSlash(client)) diff --git a/files/help.json b/files/help.json index a522c9b..f14e6f1 100644 --- a/files/help.json +++ b/files/help.json @@ -52,7 +52,7 @@ "hangman start": "Start een nieuwe Hangman game indien er nog geen bezig is. Indien je geen woord opgeeft, wordt er een willekeurig woord gekozen.\n**Indien je wel een woord opgeeft, werkt dit enkel in DM.**", "hangman guess": "Probeer het woord te raden.", "claim": "Claim [Aantal] Didier Dinks uit je profit.\nIndien je geen aantal opgeeft (of \"all\"), claim je alles, inclusief je investering.", - "inspire": "Generate quotes via [InspiroBot](https://inspirobot.me/).", + "inspire": "Genereer quotes via [InspiroBot](https://inspirobot.me/).", "inventory": "Bekijk de items in jouw inventory.", "invest": "Investeer [Aantal] Didier Dinks in jouw Didier Bank om rente te vergaren.", "jpl": "Informatie over de Jupiler Pro League.",