diff --git a/discord/member.py b/discord/member.py index e660187e6..70acedd6e 100644 --- a/discord/member.py +++ b/discord/member.py @@ -161,7 +161,8 @@ class Member(discord.abc.Messageable, _BaseUser): Nitro boost on the guild, if available. This could be ``None``. """ - __slots__ = ('_roles', 'joined_at', 'premium_since', '_client_status', 'activities', 'guild', 'nick', '_user', '_state') + __slots__ = ('_roles', '_cs_roles', 'joined_at', 'premium_since', '_client_status', + 'activities', 'guild', 'nick', '_user', '_state') def __init__(self, *, data, guild, state): self._state = state @@ -233,6 +234,11 @@ class Member(discord.abc.Messageable, _BaseUser): self.activities = member.activities self._state = member._state + try: + del self._cs_roles + except AttributeError: + pass + # Reference will not be copied unless necessary by PRESENCE_UPDATE # See below self._user = member._user @@ -244,6 +250,10 @@ class Member(discord.abc.Messageable, _BaseUser): def _update_roles(self, data): self._roles = utils.SnowflakeList(map(int, data['roles'])) + try: + del self._cs_roles + except AttributeError: + pass def _update(self, data): # the nickname change is optional, @@ -334,7 +344,7 @@ class Member(discord.abc.Messageable, _BaseUser): """ return self.colour - @property + @utils.cached_slot_property('_cs_roles') def roles(self): """List[:class:`Role`]: A :class:`list` of :class:`Role` that the member belongs to. Note that the first element of this list is always the default '@everyone'