diff options
Diffstat (limited to 'src/moyai_bot')
| -rw-r--r-- | src/moyai_bot/apis/guzzle.py | 20 | ||||
| -rw-r--r-- | src/moyai_bot/bot.py | 9 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/moyai_bot/apis/guzzle.py b/src/moyai_bot/apis/guzzle.py new file mode 100644 index 0000000..67eb34d --- /dev/null +++ b/src/moyai_bot/apis/guzzle.py @@ -0,0 +1,20 @@ +import requests + +GUZZLE: str = "https://guzzle.gay/api" + + +def get_random_teawie() -> str: + resp: requests.Response = {} + try: + resp = requests.get(GUZZLE + "/get_random_teawie", timeout=30) + except (requests.RequestException, requests.ConnectionError, + requests.HTTPError, requests.JSONDecodeError): + return "something went wrong :(" + if not resp.status_code == 200: + return "api request failed :(" + + try: + ret = resp.json()["url"] + except KeyError: + return "couldn't get url from api response :(" + return ret diff --git a/src/moyai_bot/bot.py b/src/moyai_bot/bot.py index 5b1431b..1a5ada8 100644 --- a/src/moyai_bot/bot.py +++ b/src/moyai_bot/bot.py @@ -2,6 +2,7 @@ import discord from discord import app_commands from discord.ext import commands +from moyai_bot.apis import guzzle from moyai_bot.lib import get_copypasta, get_random_response SERVER_ID = discord.Object(id=1055663552679137310) @@ -76,3 +77,11 @@ async def copypasta(interaction: discord.Interaction, await interaction.response.send_message(msg) else: await interaction.channel.send(msg) + + [email protected](name="random_teawie", + description="get a random teawie!", + guild=SERVER_ID) +async def random_teawie(interaction: discord.Interaction): + msg = guzzle.get_random_teawie() + await interaction.response.send_message(msg) |
