diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 8e8661ebe..b8d55edde 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -1095,11 +1095,21 @@ class Core(commands.Cog, CoreLogic): @_set.command() @checks.is_owner() - async def avatar(self, ctx: commands.Context, url: str): - """Sets [botname]'s avatar""" - async with aiohttp.ClientSession() as session: - async with session.get(url) as r: - data = await r.read() + async def avatar(self, ctx: commands.Context, url: str = None): + """Sets [botname]'s avatar + + Supports either an attachment or an image URL.""" + if len(ctx.message.attachments) > 0: # Attachments take priority + data = await ctx.message.attachments[0].read() + elif url is not None: + if url.startswith("<") and url.endswith(">"): + url = url[1:-1] + + async with aiohttp.ClientSession() as session: + async with session.get(url) as r: + data = await r.read() + else: + return await ctx.send(_("Please upload an attachment or provide an URL link.")) try: await ctx.bot.user.edit(avatar=data) @@ -1107,8 +1117,8 @@ class Core(commands.Cog, CoreLogic): await ctx.send( _( "Failed. Remember that you can edit my avatar " - "up to two times a hour. The URL must be a " - "direct link to a JPG / PNG." + "up to two times a hour. The URL or attachment " + "must be a valid image in either JPG or PNG format." ) ) except discord.InvalidArgument: