Skip to content

Commit

Permalink
Support for alternative role icon getters (#47)
Browse files Browse the repository at this point in the history
* Support for alternative role icon getters

* Do member check and remove nested if

* redundant else
  • Loading branch information
Kapppa authored Jun 12, 2022
1 parent 02b60ae commit 65ceaf4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion chat_exporter/construct/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,13 @@ async def _gather_user_colour(self, author: discord.Member):
async def _gather_user_icon(self, author: discord.Member):
member = await self._gather_member(author)

if member and member.display_icon:
if not member:
return ""

if hasattr(member, "display_icon") and member.display_icon:
return f"<img class='chatlog__role-icon' src='{member.display_icon}' alt='Role Icon'>"
elif hasattr(member, "top_role") and member.top_role and member.top_role.icon:
return f"<img class='chatlog__role-icon' src='{member.top_role.icon}' alt='Role Icon'>"
return ""

def set_time(self, message: Optional[discord.Message] = None):
Expand Down

0 comments on commit 65ceaf4

Please sign in to comment.