Defxult / discordLevelingSystem

A library to implement a leveling system into a discord bot. Contains features such as XP, level, ranks, and role awards.
MIT License
91 stars 17 forks source link

Users or Guilds without icons/avatars break the bot #15

Closed not-Maxx closed 2 years ago

not-Maxx commented 2 years ago

Users or Guilds without icons/avatars break the bot If something doesn't have an avatar, it'll give an error

To Reproduce Use the bare minimum code in the README

Traceback if any

Traceback (most recent call last):
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py", line 382, in _run_event
    await coro(*args, **kwargs)
  File "c:\Users\censor\Documents\Github\file-storage\Robot Maxx\cogs\levels.py", line 41, in on_message
    await self.lvl.award_xp(amount=25, message=message)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\decorators.py", line 62, in wrapper
    return await func(*args, **kwargs)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\decorators.py", line 80, in wrapper
    return await func(*args, **kwargs)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\decorators.py", line 104, in wrapper
    return await func(*args, **kwargs)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\leveling_system.py", line 1899, in award_xp
    await self._handle_level_up(message, md, leveled_up=member_level_up)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\leveling_system.py", line 1713, in _handle_level_up
    announcement_message = lua._parse_message(lua.message, self._message_author)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\announcement.py", line 212, in _parse_message
    full = self._convert_member_markdown(partial, message_author)
  File "C:\Users\censor\AppData\Local\Programs\Python\Python310\lib\site-packages\discordLevelingSystem\announcement.py", line 180, in _convert_member_markdown
    AnnouncementMember.avatar_url : message_author.avatar.url,
AttributeError: 'NoneType' object has no attribute 'url'

Required Checklist

py_cord-2.0.0.dist-info discordLevelingSystem-1.1.0-py3.10.egg-info

Defxult commented 2 years ago

This has been fixed as of https://github.com/Defxult/discordLevelingSystem/commit/ab82ab0edb91dc73c80ef0eded281be1817be9df . It should be noted that this library is no longer using pycord. I decided to fix this because it was very quick and because the error also occurred using discord.py 2.0-beta.

So yes, if you're using pycord 2.0.0, it is safe to update to version 1.2.0. But any major issues that can be fixed on the discord.py side and not the pycord side will not be updated for pycord.

Thanks for reporting the issue!