mirror of
https://github.com/MrDetonia/Maki.git
synced 2024-11-22 11:54:16 -05:00
v1.0.7 - Improved error handling for .avatar update command
This commit is contained in:
parent
9d000b4701
commit
b47a5190e3
@ -47,15 +47,22 @@ def cmd_loud(client, msg):
|
|||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def cmd_avatar(client, msg):
|
def cmd_avatar(client, msg):
|
||||||
# TODO: error-check
|
|
||||||
# unsafe, but admin command - use with care for now
|
|
||||||
url = msg.content[8:]
|
url = msg.content[8:]
|
||||||
|
response = "Avatar updated!"
|
||||||
try:
|
try:
|
||||||
response = urllib.request.urlopen(url)
|
response = urllib.request.urlopen(url)
|
||||||
imgdata = response.read()
|
imgdata = response.read()
|
||||||
yield from client.edit_profile(avatar=imgdata)
|
yield from client.edit_profile(avatar=imgdata)
|
||||||
|
except urllib.error.URLError as e:
|
||||||
|
response = "URL Error: " + e
|
||||||
|
except discord.HTTPException:
|
||||||
|
response = "Dicsord failed to edit my profile!"
|
||||||
|
except discord.InvalidArgument:
|
||||||
|
response = "Invalid image!"
|
||||||
except:
|
except:
|
||||||
yield from discord_send(client, msg, "Error updating avatar!")
|
response = "Error updating avatar!"
|
||||||
|
|
||||||
|
yield from discord_send(client, msg, response)
|
||||||
|
|
||||||
# COMMAND HANDLING
|
# COMMAND HANDLING
|
||||||
admincommands = {
|
admincommands = {
|
||||||
|
Loading…
Reference in New Issue
Block a user