Skip to content

Commit

Permalink
fix Avatar Command CL/CD errors
Browse files Browse the repository at this point in the history
CL/CD errors fix

Co-Authored-By: Cyrus Yip <[email protected]>
  • Loading branch information
martinbndr and RealCyGuy committed Feb 20, 2024
1 parent 5ecc6eb commit 8e304e9
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -2128,7 +2128,11 @@ async def avatar(self, ctx: commands.Context, url: str = None):
Updates the bots avatar within discord.
"""
if not ctx.message.attachments and url is None:
embed = discord.Embed(title='Error', description='You need to upload or link a image file.', color=self.bot.error_color)
embed = discord.Embed(
title="Error",
description="You need to upload or link a image file.",
color=self.bot.error_color
)
return await ctx.send(embed=embed)
dc_avatar = None
if ctx.message.attachments:
Expand All @@ -2139,14 +2143,23 @@ async def avatar(self, ctx: commands.Context, url: str = None):
dc_avatar = await resp.read()

if dc_avatar is None:
embed = discord.Embed(title='Error', description='Reading the attachment failed, is it valid?', color=self.bot.error_color)
embed = discord.Embed(
title="Error",
description="Reading the attachment failed, is it valid?",
color=self.bot.error_color
)
return await ctx.send(embed=embed)
try:
await self.bot.user.edit(avatar=dc_avatar)
logger.info('Bot Avatar updated.')
logger.info("Bot Avatar updated.")
except Exception:
raise ValueError('Uploading the avatar to discord failed.')
embed = discord.Embed(title='Successfully updated', description='Successfully updated avatar.', color=self.bot.main_color)
raise ValueError("Uploading the avatar to discord failed.")

embed = discord.Embed(
title="Successfully updated",
description="Successfully updated avatar.",
color=self.bot.main_color
)
await ctx.send(embed=embed)


Expand Down

0 comments on commit 8e304e9

Please sign in to comment.