From 5e17987d33cc4a1f6d8eb11e5f97627e96589631 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Mon, 24 Oct 2016 20:52:50 -0500 Subject: [PATCH 1/2] Added a check to ensure derpi provided the right information (couldn't connect --- cogs/links.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cogs/links.py b/cogs/links.py index 88cdda6..800cc55 100644 --- a/cogs/links.py +++ b/cogs/links.py @@ -169,15 +169,18 @@ class Links: await self.bot.say("Looking up an image with those tags....") - # Get the response from derpibooru and parse the 'search' result from it - async with self.session.get(url, params=params, headers=self.headers) as r: - data = await r.json() try: - results = data['search'] + # Get the response from derpibooru and parse the 'search' result from it + async with self.session.get(url, params=params, headers=self.headers) as r: + data = await r.json() + results = data['search'] except KeyError: await self.bot.say("No results with that search term, {0}!".format(ctx.message.author.mention)) return + except json.JSONDecodeError: + await self.bot.say("Sorry but I failed to connect to Derpibooru!") + return # The first request we've made ensures there are results # Now we can get the total count from that, and make another request based on the number of pages as well From 8d7e31d564c259f91c94d00001a64a31cb53c11e Mon Sep 17 00:00:00 2001 From: phxntxm Date: Tue, 25 Oct 2016 21:08:09 -0500 Subject: [PATCH 2/2] Corrected the order for one of the battle outcomes --- cogs/chess.py | 2 +- cogs/interaction.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cogs/chess.py b/cogs/chess.py index 9913193..241866e 100644 --- a/cogs/chess.py +++ b/cogs/chess.py @@ -1,9 +1,9 @@ import discord from discord.ext import commands from .utils import checks -from .utils import config import random +import re from enum import Enum class Chess: diff --git a/cogs/interaction.py b/cogs/interaction.py index d9eaa1e..4c49347 100644 --- a/cogs/interaction.py +++ b/cogs/interaction.py @@ -29,7 +29,7 @@ battle_outcomes = \ "{0} and {1} sit down for an intense game of chess, in the heat of the moment {0} forgot they were playing a game and summoned a real knight", "{0} challenges {1} to rock paper scissors, unfortunately for {1}, {0} chose scissors and stabbed them", "{0} goes back in time and becomes {1}'s best friend, winning without ever throwing a punch", - "{0} trips down some stairs on their way to the battle with {1}", + "{1} trips down some stairs on their way to the battle with {0}", "{0} books {1} a one way ticket to Flugendorf prison", "{1} was already dead", "{1} was crushed under the weight of expectations",