summaryrefslogtreecommitdiff
path: root/cogs/Animals.py
diff options
context:
space:
mode:
authorlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
committerlexicade <jasonnlelong@gmail.com>2023-01-27 21:06:30 +0000
commit52801b4de1d63cd01191acf7fcee137977140ec0 (patch)
tree08271a1f1e3e8060486b6651c67c9934867c648e /cogs/Animals.py
parent8df873808c86805624851356f5dea76ec621de23 (diff)
Project initHEADmain
Diffstat (limited to 'cogs/Animals.py')
-rw-r--r--cogs/Animals.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/cogs/Animals.py b/cogs/Animals.py
new file mode 100644
index 0000000..28b6b3f
--- /dev/null
+++ b/cogs/Animals.py
@@ -0,0 +1,46 @@
+from discord.ext import commands
+import discord
+import importlib
+import requests
+import json
+import utils
+importlib.reload(utils)
+
+
+class Animals(commands.Cog):
+ def __init__(self, bot):
+ self.bot = bot
+
+ @commands.defer(ephemeral=False)
+ @commands.command(aliases=[], application_command_meta=commands.ApplicationCommandMeta(options=[]))
+ async def dog(self, ctx):
+ """Get a dog picture!"""
+ obj_dog = await self.get_request("https://dog.ceo/api/breeds/image/random")
+ emb = await utils.embed(ctx, "Random Dog:", "", image=obj_dog["message"])
+ await ctx.send(embed=emb)
+
+ @commands.defer(ephemeral=False)
+ @commands.command(aliases=[], application_command_meta=commands.ApplicationCommandMeta(options=[]))
+ async def cat(self, ctx):
+ """Get a cat picture!"""
+ obj_cat = await self.get_request("https://api.thecatapi.com/v1/images/search")
+ emb = await utils.embed(ctx, "Random Cat:", "", image=obj_cat[0]["url"])
+ await ctx.send(embed=emb)
+
+ @staticmethod
+ async def get_request(url):
+ obj_request_get = requests.get(url)
+ if obj_request_get.status_code == 200:
+ obj_data = json.loads(obj_request_get.text)
+ return obj_data
+ else:
+ return None
+
+def setup(bot):
+ print("INFO: Loading [Animals]... ", end="")
+ bot.add_cog(Animals(bot))
+ print("Done!")
+
+
+def teardown(bot):
+ print("INFO: Unloading [Animals]")