1
0
Fork 0
mirror of synced 2024-06-29 19:50:25 +12:00
This commit is contained in:
Phxntxm 2016-10-28 18:52:43 -05:00
commit c9c60464d8
3 changed files with 9 additions and 6 deletions

View file

@ -1,9 +1,9 @@
import discord import discord
from discord.ext import commands from discord.ext import commands
from .utils import checks from .utils import checks
from .utils import config
import random import random
import re
from enum import Enum from enum import Enum

View file

@ -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} 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} 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} 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", "{0} books {1} a one way ticket to Flugendorf prison",
"{1} was already dead", "{1} was already dead",
"{1} was crushed under the weight of expectations", "{1} was crushed under the weight of expectations",

View file

@ -169,15 +169,18 @@ class Links:
await self.bot.say("Looking up an image with those tags....") await self.bot.say("Looking up an image with those tags....")
try:
# Get the response from derpibooru and parse the 'search' result from it # 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: async with self.session.get(url, params=params, headers=self.headers) as r:
data = await r.json() data = await r.json()
try:
results = data['search'] results = data['search']
except KeyError: except KeyError:
await self.bot.say("No results with that search term, {0}!".format(ctx.message.author.mention)) await self.bot.say("No results with that search term, {0}!".format(ctx.message.author.mention))
return 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 # 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 # Now we can get the total count from that, and make another request based on the number of pages as well