From 865d6ff5fa923a52c345baa3348f2ec20a44819c Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 27 Aug 2025 16:44:15 +0200 Subject: [PATCH 01/12] Add support for display_name_styles --- discord/enums.py | 23 +++++++++++++++++++++++ discord/types/user.py | 11 ++++++++++- discord/user.py | 23 ++++++++++++++++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 28b99ab03..8ccbd73c2 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -988,6 +988,29 @@ class NameplatePalette(Enum): white = 'white' +class NameFont(Enum): + default = 11 + bangers = 1 + bio_rhyme = 2 + cherry_bomb = 3 + chicle = 4 + compagnon = 5 + museo_moderno = 6 + neo_castel = 7 + pixelify = 8 + ribes = 9 + sinistre = 10 + zilla_slab = 12 + + +class NameEffect(Enum): + solid = 1 + gradient = 2 + neon = 3 + toon = 4 + pop = 5 + + def create_unknown_value(cls: Type[E], val: Any) -> E: value_cls = cls._enum_value_cls_ # type: ignore # This is narrowed below name = f'unknown_{val}' diff --git a/discord/types/user.py b/discord/types/user.py index 639384a56..83d92ec06 100644 --- a/discord/types/user.py +++ b/discord/types/user.py @@ -23,12 +23,14 @@ DEALINGS IN THE SOFTWARE. """ from .snowflake import Snowflake -from typing import Literal, Optional, TypedDict +from typing import Literal, Optional, TypedDict, List from typing_extensions import NotRequired PremiumType = Literal[0, 1, 2, 3] NameplatePallete = Literal['crimson', 'berry', 'sky', 'teal', 'forest', 'bubble_gum', 'violet', 'cobalt', 'clover'] +DisplayNameFont = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] +DisplayNameEffect = Literal[1, 2, 3, 4, 5] class _UserSKU(TypedDict): @@ -70,6 +72,12 @@ class PartialUser(TypedDict): collectibles: NotRequired[UserCollectibles] +class DisplayNameStyle(TypedDict): + font_id: DisplayNameFont + effect_id: DisplayNameEffect + colors: List[int] # 1-2 + + class User(PartialUser, total=False): bot: bool system: bool @@ -80,3 +88,4 @@ class User(PartialUser, total=False): flags: int premium_type: PremiumType public_flags: int + display_name_styles: DisplayNameStyle diff --git a/discord/user.py b/discord/user.py index 32edb1dc7..65f753003 100644 --- a/discord/user.py +++ b/discord/user.py @@ -29,7 +29,7 @@ from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import discord.abc from .asset import Asset from .colour import Colour -from .enums import DefaultAvatar +from .enums import DefaultAvatar, NameEffect, NameFont, try_enum from .flags import PublicUserFlags from .utils import snowflake_time, _bytes_to_base64_data, MISSING, _get_as_snowflake from .primary_guild import PrimaryGuild @@ -51,6 +51,7 @@ if TYPE_CHECKING: AvatarDecorationData, PrimaryGuild as PrimaryGuildPayload, UserCollectibles as UserCollectiblesPayload, + DisplayNameStyle as DisplayNameStylePayload, ) @@ -60,6 +61,16 @@ __all__ = ( ) +class DisplayNameStyle: + def __init__(self, *, data: DisplayNameStylePayload) -> None: + self.font: NameFont = try_enum(NameFont, data['font_id']) + self.effect: NameEffect = try_enum(NameEffect, data['effect_id']) + self.colors: List[discord.Colour] = [discord.Colour(color) for color in data.get('colors', [])] + + def __repr__(self) -> str: + return f'' + + class _UserTag: __slots__ = () id: int @@ -81,6 +92,7 @@ class BaseUser(_UserTag): '_avatar_decoration_data', '_primary_guild', '_collectibles', + '_display_name_style', ) if TYPE_CHECKING: @@ -98,6 +110,7 @@ class BaseUser(_UserTag): _avatar_decoration_data: Optional[AvatarDecorationData] _primary_guild: Optional[PrimaryGuildPayload] _collectibles: Optional[UserCollectiblesPayload] + _display_name_style: Optional[DisplayNameStylePayload] def __init__(self, *, state: ConnectionState, data: Union[UserPayload, PartialUserPayload]) -> None: self._state = state @@ -137,6 +150,7 @@ class BaseUser(_UserTag): self._avatar_decoration_data = data.get('avatar_decoration_data') self._primary_guild = data.get('primary_guild', None) self._collectibles = data.get('collectibles', None) + self._display_name_style = data.get('display_name_styles', None) or None @classmethod def _copy(cls, user: Self) -> Self: @@ -155,6 +169,7 @@ class BaseUser(_UserTag): self._avatar_decoration_data = user._avatar_decoration_data self._primary_guild = user._primary_guild self._collectibles = user._collectibles + self._display_name_style = user._display_name_style return self @@ -340,6 +355,12 @@ class BaseUser(_UserTag): return [] return [Collectible(state=self._state, type=key, data=value) for key, value in self._collectibles.items() if value] # type: ignore + @property + def display_name_style(self) -> Optional[DisplayNameStyle]: + if self._display_name_style is None: + return None + return DisplayNameStyle(data=self._display_name_style) + def mentioned_in(self, message: Message) -> bool: """Checks if the user is mentioned in the specified message. From 412c485fc18f572aa21c0590e592a2b3b1cb5ea1 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 27 Aug 2025 16:47:03 +0200 Subject: [PATCH 02/12] Add to Member --- discord/member.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/discord/member.py b/discord/member.py index fd2cf7edb..210b470fc 100644 --- a/discord/member.py +++ b/discord/member.py @@ -76,6 +76,7 @@ if TYPE_CHECKING: ) from .primary_guild import PrimaryGuild from .collectible import Collectible + from .user import DisplayNameStyle VocalGuildChannel = Union[VoiceChannel, StageChannel] @@ -313,6 +314,7 @@ class Member(discord.abc.Messageable, _UserTag): avatar_decoration_sku_id: Optional[int] primary_guild: PrimaryGuild collectibles: List[Collectible] + display_name_style: DisplayNameStyle def __init__(self, *, data: MemberWithUserPayload, guild: Guild, state: ConnectionState): self._state: ConnectionState = state From 654c57a40eab04f0dfaede75230cfa7bdc267c68 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:04:44 +0200 Subject: [PATCH 03/12] Format and docs --- discord/enums.py | 2 ++ discord/user.py | 13 +++++++ docs/api.rst | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) diff --git a/discord/enums.py b/discord/enums.py index 8ccbd73c2..04ead90ae 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -85,6 +85,8 @@ __all__ = ( 'MediaItemLoadingState', 'CollectibleType', 'NameplatePalette', + 'NameFont', + 'NameEffect', ) diff --git a/discord/user.py b/discord/user.py index 65f753003..caf4a070a 100644 --- a/discord/user.py +++ b/discord/user.py @@ -58,10 +58,23 @@ if TYPE_CHECKING: __all__ = ( 'User', 'ClientUser', + 'DisplayNameStyle', ) class DisplayNameStyle: + """Represents a user's display name style. + + Attributes + ----------- + font: :class:`NameFont` + The font. + effect: :class:`NameEffect` + The applied effect. + colors: List[:class:`Colour`] + The colors used in the effect. Max of 2. + """ + def __init__(self, *, data: DisplayNameStylePayload) -> None: self.font: NameFont = try_enum(NameFont, data['font_id']) self.effect: NameEffect = try_enum(NameEffect, data['effect_id']) diff --git a/docs/api.rst b/docs/api.rst index 1a564ddca..0496a9a2e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4132,6 +4132,86 @@ of :class:`enum.Enum`. The collectible nameplate palette is white. +.. class:: NameFont + + Represents the available fonts for a user display name style. + + .. versionadded:: 2.7 + + .. attribute:: default + + The default font is used. + + .. attribute:: bangers + + The 'Bangers' font is used. + + .. attribute:: bio_rhyme + + The 'BioRhyme' font is used. + + .. attribute:: cherry_bomb + + The 'Cherry Bomb' font is used. + + .. attribute:: chicle + + The 'Chicle' font is used. + + .. attribute:: compagnon + + The 'Compagnon' font is used. + + .. attribute:: museo_moderno + + The 'Museo Moderno' font is used. + + .. attribute:: neo_castel + + The 'Neo Castel' font is used. + + .. attribute:: pixelify + + The 'Pixelify' font is used. + + .. attribute:: ribes + + The 'Ribes' font is used. + + .. attribute:: sinistre + + The 'Sinistre' font is used. + + .. attribute:: zilla_slab + + The 'Zilla Slab' font is used. + +.. class:: NameEffect + + Represents the available effects for a user display name style. + + .. versionadded:: 2.7 + + .. attribute:: solid + + The first color provided is used. + + .. attribute:: gradient + + A two colour gradient is used, using both colors provided. + + .. attribute:: neon + + There is a neon glow around the name. + + .. attribute:: toon + + There is a subtle vertical gradient and stroke around the name. + + .. attribute:: pop + + A coloured drop-down shadow is shown. + .. _discord-api-audit-logs: Audit Log Data @@ -5836,6 +5916,14 @@ Collectible .. autoclass:: Collectible() :members: +DisplayNameStyle +~~~~~~~~~~~~~~~~~ + +.. attributetable:: DisplayNameStyle + +.. autoclass:: DisplayNameStyle() + :members: + CallMessage ~~~~~~~~~~~~~~~~~~~ From 135ce3f4b756b084deef3ff02fbc6c0e0ea0d418 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:10:16 +0200 Subject: [PATCH 04/12] Font 12 --- discord/types/user.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/discord/types/user.py b/discord/types/user.py index 83d92ec06..d1c218f4e 100644 --- a/discord/types/user.py +++ b/discord/types/user.py @@ -29,7 +29,7 @@ from typing_extensions import NotRequired PremiumType = Literal[0, 1, 2, 3] NameplatePallete = Literal['crimson', 'berry', 'sky', 'teal', 'forest', 'bubble_gum', 'violet', 'cobalt', 'clover'] -DisplayNameFont = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] +DisplayNameFont = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] DisplayNameEffect = Literal[1, 2, 3, 4, 5] @@ -75,7 +75,7 @@ class PartialUser(TypedDict): class DisplayNameStyle(TypedDict): font_id: DisplayNameFont effect_id: DisplayNameEffect - colors: List[int] # 1-2 + colors: List[int] class User(PartialUser, total=False): From c13efe12330aea5600f5b08f5378dde120a01884 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Wed, 27 Aug 2025 17:13:50 +0200 Subject: [PATCH 05/12] Update api.rst --- docs/api.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 0496a9a2e..b650da0e5 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4198,7 +4198,7 @@ of :class:`enum.Enum`. .. attribute:: gradient - A two colour gradient is used, using both colors provided. + There is a two colour gradient using both colors provided. .. attribute:: neon @@ -4210,7 +4210,7 @@ of :class:`enum.Enum`. .. attribute:: pop - A coloured drop-down shadow is shown. + A coloured dropshadow is shown. .. _discord-api-audit-logs: From ab32ae70696e04d432599cdf1f242cd9696ef0f1 Mon Sep 17 00:00:00 2001 From: Soheab <33902984+Soheab@users.noreply.github.com> Date: Mon, 29 Sep 2025 07:29:42 +0200 Subject: [PATCH 06/12] Add new effect: glow --- discord/enums.py | 1 + docs/api.rst | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/discord/enums.py b/discord/enums.py index 04ead90ae..670468c3e 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -1011,6 +1011,7 @@ class NameEffect(Enum): neon = 3 toon = 4 pop = 5 + glow = 6 def create_unknown_value(cls: Type[E], val: Any) -> E: diff --git a/docs/api.rst b/docs/api.rst index b650da0e5..6fe237d55 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4211,6 +4211,10 @@ of :class:`enum.Enum`. .. attribute:: pop A coloured dropshadow is shown. + .. attribute:: glow + + An alternative for the gradient style is used. + .. _discord-api-audit-logs: From 994450eefe0d563b0f82c5de3db69f12c890ae5b Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:00:35 +0200 Subject: [PATCH 07/12] Rename enums --- discord/enums.py | 8 ++++---- discord/user.py | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 7377cf2ac..30ce24626 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -87,8 +87,8 @@ __all__ = ( 'MediaItemLoadingState', 'CollectibleType', 'NameplatePalette', - 'NameFont', - 'NameEffect', + 'DisplayNameFont', + 'DisplayNameEffect', ) @@ -1008,7 +1008,7 @@ class NameplatePalette(Enum): white = 'white' -class NameFont(Enum): +class DisplayNameFont(Enum): default = 11 bangers = 1 bio_rhyme = 2 @@ -1023,7 +1023,7 @@ class NameFont(Enum): zilla_slab = 12 -class NameEffect(Enum): +class DisplayNameEffect(Enum): solid = 1 gradient = 2 neon = 3 diff --git a/discord/user.py b/discord/user.py index caf4a070a..3e3bcdfc5 100644 --- a/discord/user.py +++ b/discord/user.py @@ -29,7 +29,7 @@ from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union import discord.abc from .asset import Asset from .colour import Colour -from .enums import DefaultAvatar, NameEffect, NameFont, try_enum +from .enums import DefaultAvatar, DisplayNameEffect, DisplayNameFont, try_enum from .flags import PublicUserFlags from .utils import snowflake_time, _bytes_to_base64_data, MISSING, _get_as_snowflake from .primary_guild import PrimaryGuild @@ -67,17 +67,17 @@ class DisplayNameStyle: Attributes ----------- - font: :class:`NameFont` + font: :class:`DisplayNameFont` The font. - effect: :class:`NameEffect` + effect: :class:`DisplayNameEffect` The applied effect. colors: List[:class:`Colour`] The colors used in the effect. Max of 2. """ def __init__(self, *, data: DisplayNameStylePayload) -> None: - self.font: NameFont = try_enum(NameFont, data['font_id']) - self.effect: NameEffect = try_enum(NameEffect, data['effect_id']) + self.font: DisplayNameFont = try_enum(DisplayNameFont, data['font_id']) + self.effect: DisplayNameEffect = try_enum(DisplayNameEffect, data['effect_id']) self.colors: List[discord.Colour] = [discord.Colour(color) for color in data.get('colors', [])] def __repr__(self) -> str: From e023c48bb2bb1ca8c5f2aaad437742e020296db3 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:00:53 +0200 Subject: [PATCH 08/12] Add support member specific get and edit --- discord/member.py | 80 ++++++++++++++++++++++++++++++++++++++--- discord/types/member.py | 5 +-- 2 files changed, 78 insertions(+), 7 deletions(-) diff --git a/discord/member.py b/discord/member.py index f12dfb4ca..2a9b461f8 100644 --- a/discord/member.py +++ b/discord/member.py @@ -36,12 +36,13 @@ from .asset import Asset from .utils import MISSING from .user import BaseUser, ClientUser, User, _UserTag from .permissions import Permissions -from .enums import Status +from .enums import DisplayNameEffect, DisplayNameFont, Status from .errors import ClientException from .colour import Colour from .object import Object from .flags import MemberFlags from .presences import ClientStatus +from .user import DisplayNameStyle __all__ = ( 'VoiceState', @@ -64,7 +65,7 @@ if TYPE_CHECKING: UserWithMember as UserWithMemberPayload, ) from .types.gateway import GuildMemberUpdateEvent - from .types.user import User as UserPayload, AvatarDecorationData + from .types.user import User as UserPayload, AvatarDecorationData, DisplayNameStyle as DisplayNameStylePayload from .abc import Snowflake from .state import ConnectionState from .message import Message @@ -75,7 +76,6 @@ if TYPE_CHECKING: ) from .primary_guild import PrimaryGuild from .collectible import Collectible - from .user import DisplayNameStyle VocalGuildChannel = Union[VoiceChannel, StageChannel] @@ -290,6 +290,7 @@ class Member(discord.abc.Messageable, _UserTag): '_banner', '_flags', '_avatar_decoration_data', + '_display_name_style', ) if TYPE_CHECKING: @@ -313,7 +314,6 @@ class Member(discord.abc.Messageable, _UserTag): avatar_decoration_sku_id: Optional[int] primary_guild: PrimaryGuild collectibles: List[Collectible] - display_name_style: DisplayNameStyle def __init__(self, *, data: MemberWithUserPayload, guild: Guild, state: ConnectionState): self._state: ConnectionState = state @@ -331,6 +331,7 @@ class Member(discord.abc.Messageable, _UserTag): self._permissions: Optional[int] self._flags: int = data['flags'] self._avatar_decoration_data: Optional[AvatarDecorationData] = data.get('avatar_decoration_data') + self._display_name_style: Optional[DisplayNameStylePayload] = data.get('display_name_style') try: self._permissions = int(data['permissions']) # pyright: ignore[reportTypedDictNotRequiredAccess] except KeyError: @@ -410,6 +411,7 @@ class Member(discord.abc.Messageable, _UserTag): self._avatar = member._avatar self._banner = member._banner self._avatar_decoration_data = member._avatar_decoration_data + self._display_name_style = member._display_name_style # Reference will not be copied unless necessary by PRESENCE_UPDATE # See below @@ -440,6 +442,7 @@ class Member(discord.abc.Messageable, _UserTag): self._banner = data.get('banner') self._flags = data.get('flags', 0) self._avatar_decoration_data = data.get('avatar_decoration_data') + self._display_name_style = data.get('display_name_style') def _presence_update(self, raw: RawPresenceUpdateEvent, user: UserPayload) -> Optional[Tuple[User, User]]: self.activities = raw.activities @@ -458,10 +461,12 @@ class Member(discord.abc.Messageable, _UserTag): u._public_flags, u._avatar_decoration_data['sku_id'] if u._avatar_decoration_data is not None else None, u._primary_guild, + u._display_name_style, ) decoration_payload = user.get('avatar_decoration_data') primary_guild_payload = user.get('primary_guild', None) + display_name_style_payload = user.get('display_name_style', None) # These keys seem to always be available modified = ( user['username'], @@ -471,6 +476,7 @@ class Member(discord.abc.Messageable, _UserTag): user.get('public_flags', 0), decoration_payload['sku_id'] if decoration_payload is not None else None, primary_guild_payload, + display_name_style_payload, ) if original != modified: to_return = User._copy(self._user) @@ -482,6 +488,7 @@ class Member(discord.abc.Messageable, _UserTag): u._public_flags, u._avatar_decoration_data, u._primary_guild, + u._display_name_style, ) = ( user['username'], user['discriminator'], @@ -490,6 +497,7 @@ class Member(discord.abc.Messageable, _UserTag): user.get('public_flags', 0), decoration_payload, primary_guild_payload, + display_name_style_payload, ) # Signal to dispatch on_user_update return to_return, u @@ -660,6 +668,35 @@ class Member(discord.abc.Messageable, _UserTag): if self._banner is None: return None return Asset._from_guild_banner(self._state, self.guild.id, self.id, self._banner) + + @property + def display_name_style(self) -> Optional[DisplayNameStyle]: + """Optional[:class:`DisplayNameStyle`]: Returns the member's guild display name style if they have one, + otherwise their global display name style if they have one, otherwise ``None``. + + .. versionadded:: 2.8 + """ + return self.guild_display_name_style or self.global_display_name_style + + @property + def guild_display_name_style(self) -> Optional[DisplayNameStyle]: + """Optional[:class:`DisplayNameStyle`]: Returns the member's guild specific display name style. + if the member has no guild display name style set then ``None`` is returned. + + .. versionadded:: 2.8 + """ + if self._display_name_style is None: + return None + return DisplayNameStyle(data=self._display_name_style) + + @property + def global_display_name_style(self) -> Optional[DisplayNameStyle]: + """Optional[:class:`DisplayNameStyle`]: Returns the user's global display name style. + if the user has no global display name style set then ``None`` is returned. + + .. versionadded:: 2.8 + """ + return self._user.display_name_style @property def activity(self) -> Optional[ActivityTypes]: @@ -819,6 +856,9 @@ class Member(discord.abc.Messageable, _UserTag): avatar: Optional[bytes] = MISSING, banner: Optional[bytes] = MISSING, bio: Optional[str] = MISSING, + display_name_font: Optional[DisplayNameFont] = MISSING, + display_name_effect: Optional[DisplayNameEffect] = MISSING, + display_name_colors: Optional[List[Union[Colour, int]]] = MISSING, reason: Optional[str] = None, ) -> Optional[Member]: """|coro| @@ -904,7 +944,22 @@ class Member(discord.abc.Messageable, _UserTag): This can only be set when editing the bot's own member. .. versionadded:: 2.7 + display_name_font: Optional[:class:`DisplayNameFont`] + The new display name font for the member. Use ``None`` to remove the display name font. + This can only be set when editing the bot's own member. + + .. versionadded:: 2.8 + display_name_effect: Optional[:class:`DisplayNameEffect`] + The new display name effect for the member. Use ``None`` to remove the display name effect. + This can only be set when editing the bot's own member. + + .. versionadded:: 2.8 + display_name_colors: Optional[List[Union[:class:`Colour`, :class:`int`]]] + A list of up to 2 colors that will be used for the member's display name + gradient. This can only be set when editing the bot's own member. + Use ``None`` to remove the display name colors. + .. versionadded:: 2.8 reason: Optional[:class:`str`] The reason for editing this member. Shows up on the audit log. @@ -954,8 +1009,23 @@ class Member(discord.abc.Messageable, _UserTag): if bio is not MISSING: self_payload['bio'] = bio or '' + if display_name_font is not MISSING: + self_payload['display_name_font_id'] = display_name_font.value if display_name_font else None + + if display_name_effect is not MISSING: + self_payload['display_name_effect_id'] = display_name_effect.value if display_name_effect else None + + if display_name_colors is not MISSING: + self_payload['display_name_colors'] = [ + c.value if isinstance(c, Colour) else c for c in display_name_colors or [] + ] + if not me and self_payload: - raise ValueError("Editing the bio, avatar or banner is only for the bot's own member.") + only_fields = {'avatar', 'banner', 'bio', 'display_name_font', 'display_name_effect', 'display_name_colors'} + current_fields = utils._human_join(list(only_fields.intersection(set(self_payload.keys()))), final="and") + raise ValueError( + f'Editing {current_fields} can only happen when editing the bot\'s own member.' + ) if deafen is not MISSING: payload['deaf'] = deafen diff --git a/discord/types/member.py b/discord/types/member.py index 576ef421d..17c7eaac2 100644 --- a/discord/types/member.py +++ b/discord/types/member.py @@ -24,7 +24,7 @@ DEALINGS IN THE SOFTWARE. from typing import Optional, TypedDict from .snowflake import SnowflakeList -from .user import User, AvatarDecorationData +from .user import User, AvatarDecorationData, DisplayNameStyle from typing_extensions import NotRequired @@ -50,6 +50,7 @@ class Member(PartialMember, total=False): communication_disabled_until: str banner: NotRequired[Optional[str]] avatar_decoration_data: NotRequired[AvatarDecorationData] + display_name_style: NotRequired[DisplayNameStyle] class _OptionalMemberWithUser(PartialMember, total=False): @@ -60,7 +61,7 @@ class _OptionalMemberWithUser(PartialMember, total=False): permissions: str communication_disabled_until: str avatar_decoration_data: NotRequired[AvatarDecorationData] - + display_name_style: NotRequired[DisplayNameStyle] class MemberWithUser(_OptionalMemberWithUser): user: User From 93fafb669ade752828298efef42c4b67b1b4e45c Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:02:38 +0200 Subject: [PATCH 09/12] Ruff format --- discord/enums.py | 2 +- discord/member.py | 16 +++++++--------- discord/types/member.py | 1 + 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/discord/enums.py b/discord/enums.py index 30ce24626..11c631c37 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -1029,7 +1029,7 @@ class DisplayNameEffect(Enum): neon = 3 toon = 4 pop = 5 - glow = 6 + glow = 6 def create_unknown_value(cls: Type[E], val: Any) -> E: diff --git a/discord/member.py b/discord/member.py index 2a9b461f8..0095aa188 100644 --- a/discord/member.py +++ b/discord/member.py @@ -668,16 +668,16 @@ class Member(discord.abc.Messageable, _UserTag): if self._banner is None: return None return Asset._from_guild_banner(self._state, self.guild.id, self.id, self._banner) - + @property def display_name_style(self) -> Optional[DisplayNameStyle]: - """Optional[:class:`DisplayNameStyle`]: Returns the member's guild display name style if they have one, + """Optional[:class:`DisplayNameStyle`]: Returns the member's guild display name style if they have one, otherwise their global display name style if they have one, otherwise ``None``. .. versionadded:: 2.8 """ return self.guild_display_name_style or self.global_display_name_style - + @property def guild_display_name_style(self) -> Optional[DisplayNameStyle]: """Optional[:class:`DisplayNameStyle`]: Returns the member's guild specific display name style. @@ -688,7 +688,7 @@ class Member(discord.abc.Messageable, _UserTag): if self._display_name_style is None: return None return DisplayNameStyle(data=self._display_name_style) - + @property def global_display_name_style(self) -> Optional[DisplayNameStyle]: """Optional[:class:`DisplayNameStyle`]: Returns the user's global display name style. @@ -947,7 +947,7 @@ class Member(discord.abc.Messageable, _UserTag): display_name_font: Optional[:class:`DisplayNameFont`] The new display name font for the member. Use ``None`` to remove the display name font. This can only be set when editing the bot's own member. - + .. versionadded:: 2.8 display_name_effect: Optional[:class:`DisplayNameEffect`] The new display name effect for the member. Use ``None`` to remove the display name effect. @@ -1022,10 +1022,8 @@ class Member(discord.abc.Messageable, _UserTag): if not me and self_payload: only_fields = {'avatar', 'banner', 'bio', 'display_name_font', 'display_name_effect', 'display_name_colors'} - current_fields = utils._human_join(list(only_fields.intersection(set(self_payload.keys()))), final="and") - raise ValueError( - f'Editing {current_fields} can only happen when editing the bot\'s own member.' - ) + current_fields = utils._human_join(list(only_fields.intersection(set(self_payload.keys()))), final='and') + raise ValueError(f"Editing {current_fields} can only happen when editing the bot's own member.") if deafen is not MISSING: payload['deaf'] = deafen diff --git a/discord/types/member.py b/discord/types/member.py index 17c7eaac2..00e3ae383 100644 --- a/discord/types/member.py +++ b/discord/types/member.py @@ -63,6 +63,7 @@ class _OptionalMemberWithUser(PartialMember, total=False): avatar_decoration_data: NotRequired[AvatarDecorationData] display_name_style: NotRequired[DisplayNameStyle] + class MemberWithUser(_OptionalMemberWithUser): user: User From 0685f71da4d5467b13aee8034f4c3e149abdc098 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:08:32 +0200 Subject: [PATCH 10/12] Document User.display_name_style --- discord/user.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/discord/user.py b/discord/user.py index 3e3bcdfc5..afdf8244b 100644 --- a/discord/user.py +++ b/discord/user.py @@ -370,6 +370,10 @@ class BaseUser(_UserTag): @property def display_name_style(self) -> Optional[DisplayNameStyle]: + """Optional[:class:`DisplayNameStyle`]: Returns the user's display name style. + + .. versionadded:: 2.8 + """ if self._display_name_style is None: return None return DisplayNameStyle(data=self._display_name_style) From 74bf7d0917025fd5757933608608993887771878 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:09:14 +0200 Subject: [PATCH 11/12] Rename enums and update versionadded --- docs/api.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index da79c3c51..7f943f719 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4154,11 +4154,11 @@ of :class:`enum.Enum`. The collectible nameplate palette is white. -.. class:: NameFont +.. class:: DisplayNameFont Represents the available fonts for a user display name style. - .. versionadded:: 2.7 + .. versionadded:: 2.8 .. attribute:: default @@ -4208,11 +4208,11 @@ of :class:`enum.Enum`. The 'Zilla Slab' font is used. -.. class:: NameEffect +.. class:: DisplayNameEffect Represents the available effects for a user display name style. - .. versionadded:: 2.7 + .. versionadded:: 2.8 .. attribute:: solid From 5633d80459cd81e24f3b43926c55665036a1d201 Mon Sep 17 00:00:00 2001 From: Soheab_ <33902984+Soheab@users.noreply.github.com> Date: Tue, 9 Jun 2026 12:11:39 +0200 Subject: [PATCH 12/12] format --- discord/user.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/discord/user.py b/discord/user.py index afdf8244b..d5d97a62e 100644 --- a/discord/user.py +++ b/discord/user.py @@ -371,7 +371,7 @@ class BaseUser(_UserTag): @property def display_name_style(self) -> Optional[DisplayNameStyle]: """Optional[:class:`DisplayNameStyle`]: Returns the user's display name style. - + .. versionadded:: 2.8 """ if self._display_name_style is None: