about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorredcreeper14385 <mounderfod@gmail.com>2021-08-31 17:35:22 +0100
committerredcreeper14385 <mounderfod@gmail.com>2021-08-31 17:35:22 +0100
commit215869f6d3c43ba7ebffb4735a9dfaaa69358adc (patch)
tree88613d4d8f6775f196062de1da535e276cf36ffb
parentb3a8ce5701a9fd60a8021bd1bd744614cb9a17f0 (diff)
downloadtiny-potato-bot-215869f6d3c43ba7ebffb4735a9dfaaa69358adc.tar.gz
Improve the drama command, and fix a broken source
-rw-r--r--cogs/fun.py25
1 files changed, 12 insertions, 13 deletions
diff --git a/cogs/fun.py b/cogs/fun.py
index 3ce1ed1..c105934 100644
--- a/cogs/fun.py
+++ b/cogs/fun.py
@@ -2,6 +2,7 @@ import discord
 import requests
 from discord.ext import commands
 import urllib.request
+import random
 
 class Fun(commands.Cog):
     def __init__(self, bot):
@@ -10,25 +11,23 @@ class Fun(commands.Cog):
     @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>
+    If no source (or an invalid source) is provided then a random one is picked from between the two.
     """)
-    async def drama(self, ctx, source):
+    async def drama(self, ctx, source=None):
+        url = ""
         if source == "fabric":
-            response = urllib.request.urlopen("https://fabric-drama.herokuapp.com/txt").read().decode('utf-8')
-            await ctx.send(response)
-        elif source == "ftb":
-            try:
-                response = urllib.request.urlopen("http://ftb-drama.herokuapp.com/txt").read().decode('utf-8')
-                await ctx.send(response)
-            except HTTPError:
-                await ctx.send("This site is currently unavailable.")
+            url = "https://fabric-drama.herokuapp.com/txt"
         elif source == "forge":
-            response = urllib.request.urlopen("https://mc-drama.herokuapp.com/raw").read().decode('utf-8')
-            await ctx.send(response)
+            url = "https://mc-drama.herokuapp.com/raw"
         else:
-            await ctx.send(f'Could not find drama from source "{source}". Valid sources: `ftb`, `fabric`, `forge`.')
+            url = random.choice(["https://fabric-drama.herokuapp.com/txt", "https://mc-drama.herokuapp.com/raw"])
+        response = urllib.request.urlopen(url).read().decode('utf-8')
+        embed = discord.Embed(color=0xa37dca)
+        embed.add_field(name=f"{ctx.author.name} caused drama!", value=response, inline=False)
+        embed.set_footer(text="Tiny Potato Bot v1.0.0")
+        await ctx.send(embed=embed)
 
     @commands.command(name="mixinerror", brief="helpful Mixin errors when?", help="helpful Mixin errors when?")
     async def mixinerror(self, ctx):