Corrected how to wrap the BytesIO object
This commit is contained in:
parent
6383b0bced
commit
821f33f5d1
|
@ -54,15 +54,12 @@ def find_command(bot, command):
|
||||||
async def download_image(url):
|
async def download_image(url):
|
||||||
"""Returns a file-like object based on the URL provided"""
|
"""Returns a file-like object based on the URL provided"""
|
||||||
headers = {'User-Agent': config.user_agent}
|
headers = {'User-Agent': config.user_agent}
|
||||||
try:
|
# Simply download the image
|
||||||
# Simply download the image
|
with aiohttp.ClientSession(headers=headers) as session:
|
||||||
with aiohttp.ClientSession(headers=headers) as session:
|
async with session.get(url) as r:
|
||||||
async with session.get(url) as r:
|
# Then wrap it in a BytesIO object, to be used like an actual file
|
||||||
image_bytes = r.read()
|
image = io.BytesIO(await r.read())
|
||||||
# Then wrap it in a BytesIO object, to be used like an actual file
|
return image
|
||||||
return io.BytesIO(image_bytes)
|
|
||||||
except:
|
|
||||||
return
|
|
||||||
|
|
||||||
async def update_records(key, winner, loser):
|
async def update_records(key, winner, loser):
|
||||||
# We're using the Harkness scale to rate
|
# We're using the Harkness scale to rate
|
||||||
|
|
Loading…
Reference in a new issue