about summary refs log tree commit diff stats
path: root/cogs
diff options
context:
space:
mode:
authorredcreeper14385 <mounderfod@gmail.com>2021-07-21 15:58:30 +0100
committerredcreeper14385 <mounderfod@gmail.com>2021-07-21 15:58:30 +0100
commitda46644c61a99ee288a0c78369fe7afeec43f3ba (patch)
treead4acc426e6d901857a3c91c78290eae5201f9c1 /cogs
downloadtiny-potato-bot-da46644c61a99ee288a0c78369fe7afeec43f3ba.tar.gz
feat: initial commit, about and fun commands
Diffstat (limited to 'cogs')
-rw-r--r--cogs/about.py21
-rw-r--r--cogs/fun.py52
2 files changed, 73 insertions, 0 deletions
diff --git a/cogs/about.py b/cogs/about.py
new file mode 100644
index 0000000..c9ed7e1
--- /dev/null
+++ b/cogs/about.py
@@ -0,0 +1,21 @@
+import discord
+from discord.ext import commands
+
+class About(commands.Cog):
+    def __init__(self, bot):
+        self.bot = bot
+
+    @commands.command(name="about", brief="Gives information about the bot.", help="Gives information about the bot.")
+    async def about(self, ctx):
+        embed = discord.Embed(title="Tiny Potato Bot",
+                              description="The creator of Tiny Potato Bot is mounderfod (aka redcreeper14385), find him here:",
+                              color=0xa37dca)
+        embed.add_field(name="GitHub", value="https://github.com/redcreeper14385", inline=False)
+        embed.add_field(name="Twitch", value="https://twitch.tv/mounderfod", inline=False)
+        embed.add_field(name="Discord", value="mounderfod#4179", inline=False)
+        embed.add_field(name="Reddit", value="https://www.reddit.com/user/mounderfod", inline=False)
+        embed.set_footer(text="Tiny Potato Bot v1.0.0")
+        await ctx.send(embed=embed)
+
+def setup(bot):
+    bot.add_cog(About(bot))
\ No newline at end of file
diff --git a/cogs/fun.py b/cogs/fun.py
new file mode 100644
index 0000000..be58e08
--- /dev/null
+++ b/cogs/fun.py
@@ -0,0 +1,52 @@
+import discord
+import requests
+from discord.ext import commands
+import urllib.request
+
+class Fun(commands.Cog):
+    def __init__(self, bot):
+        self.bot = bot
+
+    @commands.command(name="drama", brief="Wait, it's all discord-meta? Always has been.", help="""
+    Fetches drama from various sources, all based on asiekierka's original generator.
+    Valid sources:
+    `ftb`: <http://ftb-drama.herokuapp.com>
+    `fabric`: <http://fabric-drama.herokuapp.com>
+    `forge`: <http://mc-drama.herokuapp.com>
+    """)
+    async def drama(self, ctx, source):
+        if source == "fabric":
+            response = urllib.request.urlopen("https://fabric-drama.herokuapp.com/txt").read().decode('utf-8')
+            await ctx.send(response)
+        elif source == "ftb":
+            response = urllib.request.urlopen("http://ftb-drama.herokuapp.com/txt").read().decode('utf-8')
+            await ctx.send(response)
+        elif source == "forge":
+            response = urllib.request.urlopen("https://mc-drama.herokuapp.com/raw").read().decode('utf-8')
+            await ctx.send(response)
+        else:
+            await ctx.send(f'Could not find drama from source "{source}". Valid sources: `ftb`, `fabric`, `forge`.')
+
+    @commands.command(name="mixinerror", brief="helpful Mixin errors when?", help="helpful Mixin errors when?")
+    async def mixinerror(self, ctx):
+        await ctx.send("https://i.imgur.com/bOLCsd4.png")
+
+    @commands.command(name="xkcd", brief="Gets XKCD comics.", help="Gets comics from https://xkcd.com, with the given number.")
+    async def xkcd(self, ctx, comic):
+        if int(comic) == 0:
+            await ctx.send("Invalid comic number!")
+        if int(comic) == 1 and int(comic) != "1":
+            await ctx.send("Invalid input!")
+        else:
+            try:
+                response = requests.get(f'https://xkcd.com/{comic}/info.0.json').json()
+                embed = discord.Embed(title=f"XKCD {response['num']}: {response['safe_title']}", colour=0xa37dca)
+                embed.set_image(url=response['img'])
+                embed.set_footer(text=response['alt'])
+                await ctx.send(embed=embed)
+            except:
+                await ctx.send("An error occurred. This is most likely because you entered a number for a comic that doesn't exist.")
+
+
+def setup(bot):
+    bot.add_cog(Fun(bot))
\ No newline at end of file