Handle aiohttp errors in [p]set avatar (#4437)

* [Core comands] Handle aiohttp errors in set avatar

* Update redbot/core/core_commands.py

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
PredaaA 2020-09-19 19:51:38 +02:00 committed by GitHub
parent 4e1ce7524b
commit 343efba4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1776,8 +1776,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
url = url[1:-1]
async with aiohttp.ClientSession() as session:
try:
async with session.get(url) as r:
data = await r.read()
except aiohttp.InvalidURL:
return await ctx.send(_("That URL is invalid."))
except aiohttp.ClientError:
return await ctx.send(_("Something went wrong while trying to get the image."))
else:
await ctx.send_help()
return