diff --git a/CHANGELOG.md b/CHANGELOG.md index 9515f21e80..bfe1288a10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,17 @@ These changes are available on the `master` branch, but have not yet been releas ### Added +- Added `RoleColours.HOLOGRAPHIC_PRIMARY`, `RoleColours.HOLOGRAPHIC_SECONDARY`, and + `RoleColours.HOLOGRAPHIC_TERTIARY` class constants. + ([#3268](https://github.com/Pycord-Development/pycord/pull/3268)) + ### Changed ### Fixed +- Fixed an `AttributeError` when using `RoleColours.is_holographic` and `secondary` or + `tertiary` is `None`. + ([#3268](https://github.com/Pycord-Development/pycord/pull/3268)) - Fix error message for `Guild.create_sticker`. ([#3263](https://github.com/Pycord-Development/pycord/pull/3263)) - Fix typehint for `SlashCommandGroup.__new__`. diff --git a/discord/role.py b/discord/role.py index c37c2f5a4f..e7d24a6f83 100644 --- a/discord/role.py +++ b/discord/role.py @@ -308,9 +308,19 @@ class RoleColours: secondary: Optional[:class:`Colour`] The secondary colour of the role. tertiary: Optional[:class:`Colour`] - The tertiary colour of the role. At the moment, only `16761760` is allowed. + The tertiary colour of the role. At the moment, only :attr:`HOLOGRAPHIC_TERTIARY` is allowed. + HOLOGRAPHIC_PRIMARY: :class:`Colour` + The primary colour used for holographic roles. + HOLOGRAPHIC_SECONDARY: :class:`Colour` + The secondary colour used for holographic roles. + HOLOGRAPHIC_TERTIARY: :class:`Colour` + The tertiary colour used for holographic roles. """ + HOLOGRAPHIC_PRIMARY = Colour(11127295) + HOLOGRAPHIC_SECONDARY = Colour(16759788) + HOLOGRAPHIC_TERTIARY = Colour(16761760) + def __init__( self, primary: Colour, @@ -362,20 +372,26 @@ def default(cls) -> RoleColours: def holographic(cls) -> RoleColours: """Returns a :class:`RoleColours` that makes the role look holographic. - Currently holographic roles are only supported with colours 11127295, 16759788, and 16761760. + Currently holographic roles are only supported with colours defined in + :attr:`HOLOGRAPHIC_PRIMARY`, :attr:`HOLOGRAPHIC_SECONDARY`, and :attr:`HOLOGRAPHIC_TERTIARY`. """ - return cls(Colour(11127295), Colour(16759788), Colour(16761760)) + return cls( + cls.HOLOGRAPHIC_PRIMARY, + cls.HOLOGRAPHIC_SECONDARY, + cls.HOLOGRAPHIC_TERTIARY, + ) @property def is_holographic(self) -> bool: """Whether the role is holographic. - Currently roles are holographic when colours are set to 11127295, 16759788, and 16761760. + Currently roles are holographic when colours are set to + :attr:`HOLOGRAPHIC_PRIMARY`, :attr:`HOLOGRAPHIC_SECONDARY`, and :attr:`HOLOGRAPHIC_TERTIARY`. """ return ( - self.primary.value == 11127295 - and self.secondary.value == 16759788 - and self.tertiary.value == 16761760 + self.primary == self.HOLOGRAPHIC_PRIMARY + and self.secondary == self.HOLOGRAPHIC_SECONDARY + and self.tertiary == self.HOLOGRAPHIC_TERTIARY ) def __repr__(self) -> str: