diff --git a/bot/extensions/levelling/commands.py b/bot/extensions/levelling/commands.py index 1e42b82e..3caefa29 100644 --- a/bot/extensions/levelling/commands.py +++ b/bot/extensions/levelling/commands.py @@ -115,6 +115,8 @@ async def on_message(self, message): def generate_rank_image(self, username: str, avatar_bytes: bytes, rank: int, level: int, xp: int, required_xp: int): img = Image.new("RGBA", (1000, 240)) logo = Image.open(BytesIO(avatar_bytes)).resize((200, 200)) + if logo.mode != "RGBA": + logo = logo.convert("RGBA") # Paste the default background image onto the new image img.paste(self.background, (0, 0)) @@ -282,7 +284,10 @@ async def rank(self, interaction: core.InteractionType, member: discord.Member = return await interaction.response.send_message("That user is not ranked yet...", ephemeral=True) # Fetch the user's avatar as bytes - avatar_bytes = await member.display_avatar.with_format("png").read() + try: + avatar_bytes = await member.display_avatar.with_format("png").read() + except discord.errors.NotFound: + avatar_bytes = await member.default_avatar.with_format("png").read() level = utils.get_level_for_xp(record.total_xp) prev_xp = utils.get_xp_for_level(level)