Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 37 additions & 11 deletions discord/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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]:
Expand Down