diff --git a/CHANGELOG.md b/CHANGELOG.md index f3659e604b..1d4ad17405 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,11 +14,15 @@ These changes are available on the `master` branch, but have not yet been releas - Added `.extension` attribute to emojis to get their file extension. ([#3055](https://github.com/Pycord-Development/pycord/pull/3055)) +- Added `Member.colours` and `Member.colors` properties. + ([#3063](https://github.com/Pycord-Development/pycord/pull/3063)) ### Changed - Updated `Role.is_assignable()` to also check whether the bot has the `MANAGE_ROLES` permission. ([#3048](https://github.com/Pycord-Development/pycord/pull/3048)) +- Changed `Member.colour` and `Member.color` to be aliases for `Member.colours.primary`. + ([#3063](https://github.com/Pycord-Development/pycord/pull/3063)) ### Fixed diff --git a/discord/member.py b/discord/member.py index 72cbb912d9..5dd9459d64 100644 --- a/discord/member.py +++ b/discord/member.py @@ -44,6 +44,7 @@ from .object import Object from .permissions import Permissions from .primary_guild import PrimaryGuild +from .role import RoleColours from .user import BaseUser, User, _UserTag from .utils import MISSING @@ -61,6 +62,7 @@ from .role import Role from .state import ConnectionState from .types.activity import PartialPresenceUpdate + from .types.member import Member from .types.member import Member as MemberPayload from .types.member import MemberWithUser as MemberWithUserPayload from .types.member import UserWithMember as UserWithMemberPayload @@ -529,11 +531,33 @@ def is_on_mobile(self) -> bool: @property def colour(self) -> Colour: - """A property that returns a colour denoting the rendered colour + """A property that returns a colour denoting the rendered primary colour for the member. If the default colour is the one rendered then an instance of :meth:`Colour.default` is returned. - There is an alias for this named :attr:`color`. + This is an alias for ``Member.colours.primary``. + """ + return self.colours.primary + + @property + def color(self) -> Colour: + """A property that returns a color denoting the primary rendered color for + the member. If the default color is the one rendered then an instance of :meth:`Colour.default` + is returned. + + This is an alias for ``Member.colours.primary``. + """ + return self.colours.primary + + @property + def colours(self) -> RoleColours: + """A property that returns the rendered :class:`RoleColours` for + the member. If the default color is the one rendered then an instance of :meth:`RoleColours.default` + is returned. + + There is an alias for this named :attr:`colors`. + + .. versionadded:: 2.8 """ roles = self.roles[1:] # remove @everyone @@ -542,19 +566,21 @@ def colour(self) -> Colour: # if the highest is the default colour then the next one with a colour # is chosen instead for role in reversed(roles): - if role.colour.value: - return role.colour - return Colour.default() + if role.colours.primary.value: + return role.colours + return RoleColours.default() @property - def color(self) -> Colour: - """A property that returns a color denoting the rendered color for - the member. If the default color is the one rendered then an instance of :meth:`Colour.default` - is returned. + def colors(self) -> RoleColours: + """A property that returns the rendered :class:`RoleColours` for the member. + If the default color is the one rendered then an instance + of :meth:`Colour.default` is returned. + + This is an alias for :attr:`colours`. - There is an alias for this named :attr:`colour`. + .. versionadded:: 2.8 """ - return self.colour + return self.colours @property def roles(self) -> list[Role]: