Added an error check for an issue where e621 provides data that is not json encodable
This commit is contained in:
parent
a51ef0879a
commit
a3d1c7ea63
|
@ -7,6 +7,7 @@ import aiohttp
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import math
|
import math
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
class Links:
|
class Links:
|
||||||
|
@ -142,9 +143,12 @@ class Links:
|
||||||
url += "%20rating:explicit"
|
url += "%20rating:explicit"
|
||||||
else:
|
else:
|
||||||
url += "%20rating:safe"
|
url += "%20rating:safe"
|
||||||
|
try:
|
||||||
async with self.session.get(url, headers=self.headers) as r:
|
async with self.session.get(url, headers=self.headers) as r:
|
||||||
data = await r.json()
|
data = await r.json()
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
await self.bot.say("Sorry, I had trouble connecting at the moment; please try again later")
|
||||||
|
return
|
||||||
|
|
||||||
# Try to find an image from the list. If there were no results, we're going to attempt to find
|
# Try to find an image from the list. If there were no results, we're going to attempt to find
|
||||||
# A number between (0,-1) and receive an error.
|
# A number between (0,-1) and receive an error.
|
||||||
|
|
Loading…
Reference in a new issue