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
This commit is contained in:
		@@ -129,6 +129,9 @@ async def member_avatar(ctx: CommandContext, member: Member):
 | 
				
			|||||||
        if user:
 | 
					        if user:
 | 
				
			||||||
            new_avatar_url = user.avatar_url_as(format="png")
 | 
					            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 member.set_avatar(ctx.conn, new_avatar_url)
 | 
				
			||||||
    await ctx.reply_ok("Member avatar {}.".format("updated" if new_avatar_url else "cleared"))
 | 
					    await ctx.reply_ok("Member avatar {}.".format("updated" if new_avatar_url else "cleared"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -185,6 +185,9 @@ async def system_avatar(ctx: CommandContext):
 | 
				
			|||||||
        if user:
 | 
					        if user:
 | 
				
			||||||
            new_avatar_url = user.avatar_url_as(format="png")
 | 
					            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 system.set_avatar(ctx.conn, new_avatar_url)
 | 
				
			||||||
    await ctx.reply_ok("System avatar {}.".format("updated" if new_avatar_url else "cleared"))
 | 
					    await ctx.reply_ok("System avatar {}.".format("updated" if new_avatar_url else "cleared"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user