From 2b3cc8fe101744987a8967ef440cbdbc5f3922d9 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 17 Apr 2022 15:58:16 -0400 Subject: [PATCH] Add Member.display_icon to get the rendered member icon --- discord/member.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/discord/member.py b/discord/member.py index c3b848008..367d8de7d 100644 --- a/discord/member.py +++ b/discord/member.py @@ -548,6 +548,22 @@ class Member(discord.abc.Messageable, _UserTag): result.sort() return result + @property + def display_icon(self) -> Optional[Union[str, Asset]]: + """Optional[Union[:class:`str`, :class:`Asset`]]: A property that returns the role icon that is rendered for + this member. If no icon is shown then ``None`` is returned. + + .. versionadded:: 2.0 + """ + + roles = self.roles[1:] # remove @everyone + for role in reversed(roles): + icon = role.display_icon + if icon: + return icon + + return None + @property def mention(self) -> str: """:class:`str`: Returns a string that allows you to mention the member."""