Catch race condition
This commit is contained in:
parent
fbb5873884
commit
4f8f606609
|
@ -3,7 +3,6 @@ import discord
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import math
|
import math
|
||||||
import glob
|
|
||||||
from bs4 import BeautifulSoup as bs
|
from bs4 import BeautifulSoup as bs
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
|
@ -25,9 +24,12 @@ class Images:
|
||||||
opts = {"format": "src"}
|
opts = {"format": "src"}
|
||||||
result = await utils.request(url, attr='url', payload=opts)
|
result = await utils.request(url, attr='url', payload=opts)
|
||||||
|
|
||||||
image = await utils.download_image(result)
|
try:
|
||||||
f = discord.File(image, filename=result.name)
|
image = await utils.download_image(result)
|
||||||
await ctx.send(file=f)
|
f = discord.File(image, filename=result.name)
|
||||||
|
await ctx.send(file=f)
|
||||||
|
except (ValueError, AttributeError):
|
||||||
|
await ctx.send("I couldn't connect! Sorry no cats right now ;w;")
|
||||||
|
|
||||||
@commands.command(aliases=['dog', 'rd'])
|
@commands.command(aliases=['dog', 'rd'])
|
||||||
@utils.custom_perms(send_messages=True)
|
@utils.custom_perms(send_messages=True)
|
||||||
|
|
Loading…
Reference in a new issue