about summary refs log tree commit diff stats
path: root/cogs
diff options
context:
space:
mode:
authorredcreeper14385 <mounderfod@gmail.com>2021-07-22 12:25:40 +0100
committerredcreeper14385 <mounderfod@gmail.com>2021-07-22 12:26:23 +0100
commitaeb57f55d642ac0a02c9c0ad23988fcdbc897c1c (patch)
tree2bb1a0c082cba68714c8dabaf3a04e91e06d6805 /cogs
parentd8f48844f9616ac8e9a30159118d37ebf1830b7c (diff)
downloadtiny-potato-bot-aeb57f55d642ac0a02c9c0ad23988fcdbc897c1c.tar.gz
feat: add modrinth command
Diffstat (limited to 'cogs')
-rw-r--r--cogs/modrinth.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/cogs/modrinth.py b/cogs/modrinth.py
new file mode 100644
index 0000000..85ed972
--- /dev/null
+++ b/cogs/modrinth.py
@@ -0,0 +1,24 @@
+import discord
+from discord.ext import commands
+import requests
+
+class Modrinth(commands.Cog):
+    def __init__(self, bot):
+        self.bot = bot
+
+    @commands.command(name="modrinth", brief="Finds a given mod on Modrinth.", help="""Finds a given mod on Modrinth.
+    You can provide either the slug (`fabric-for-fabric`) or the project ID (`u6KTKg89`).
+    If you get a JSONDecodeError it's because the mod could not be found!""", aliases=['mr', 'modr'])
+    async def modrinth(self, ctx, mod): # 5da426
+        response = requests.get(f'https://api.modrinth.com/api/v1/mod/{mod}').json()
+        embed = discord.Embed(title = response['title'], url=f'https://modrinth.com/mod/{mod}', description = response['description'], color = 0x5da426)
+        embed.set_thumbnail(url = response['icon_url'])
+        embed.add_field(name='Mod ID', value = response['id'], inline=True)
+        embed.add_field(name='Categories', value = ', '.join(response['categories']), inline=True)
+        embed.add_field(name='Downloads', value = response['downloads'], inline=True)
+        embed.set_footer(text='Tiny Potato Bot')
+        await ctx.send(embed=embed)
+
+
+def setup(bot):
+    bot.add_cog(Modrinth(bot))
\ No newline at end of file