From 9cc1d899a68ee0bb14acfa4070c190cd95492c9b Mon Sep 17 00:00:00 2001 From: Grey Himmel Date: Fri, 3 May 2019 08:50:46 -0400 Subject: [PATCH] bot: get avatar url from attachment if not given directly * Update member_commands.py Add ability to get avatar image from an attachment * Update system_commands.py Adding ability to get avatar from an attachment --- src/pluralkit/bot/commands/member_commands.py | 3 +++ src/pluralkit/bot/commands/system_commands.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/pluralkit/bot/commands/member_commands.py b/src/pluralkit/bot/commands/member_commands.py index 5f1f7a23..5d335e4a 100644 --- a/src/pluralkit/bot/commands/member_commands.py +++ b/src/pluralkit/bot/commands/member_commands.py @@ -128,6 +128,9 @@ async def member_avatar(ctx: CommandContext, member: Member): user = await utils.parse_mention(ctx.client, new_avatar_url) if user: new_avatar_url = user.avatar_url_as(format="png") + + if not new_avatar_url and ctx.message.attachments[0]: + new_avatar_url = ctx.message.attachments[0].url await member.set_avatar(ctx.conn, new_avatar_url) await ctx.reply_ok("Member avatar {}.".format("updated" if new_avatar_url else "cleared")) diff --git a/src/pluralkit/bot/commands/system_commands.py b/src/pluralkit/bot/commands/system_commands.py index 0e50d754..be60d862 100644 --- a/src/pluralkit/bot/commands/system_commands.py +++ b/src/pluralkit/bot/commands/system_commands.py @@ -184,6 +184,9 @@ async def system_avatar(ctx: CommandContext): user = await utils.parse_mention(ctx.client, new_avatar_url) if user: new_avatar_url = user.avatar_url_as(format="png") + + if not new_avatar_url and ctx.message.attachments[0]: + new_avatar_url = ctx.message.attachments[0].url await system.set_avatar(ctx.conn, new_avatar_url) await ctx.reply_ok("System avatar {}.".format("updated" if new_avatar_url else "cleared"))