From 9ebc13e160cd339f000d80d1d00dc625ab27b9c0 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Thu, 4 May 2023 21:56:34 -0400 Subject: [PATCH] Only use @ prefix in __str__ if the user is migrated --- discord/member.py | 2 +- discord/team.py | 4 ++-- discord/user.py | 8 +++++--- discord/widget.py | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/discord/member.py b/discord/member.py index dad54deb0..a45fcae43 100644 --- a/discord/member.py +++ b/discord/member.py @@ -274,7 +274,7 @@ class Member(discord.abc.Messageable, _UserTag): .. describe:: str(x) - Returns the member's name with a ``@``. + Returns the member's handle (e.g. ``@user`` or ``user#discriminator``). Attributes ---------- diff --git a/discord/team.py b/discord/team.py index 6539e07e2..89bc2cfa1 100644 --- a/discord/team.py +++ b/discord/team.py @@ -108,7 +108,7 @@ class TeamMember(BaseUser): .. describe:: str(x) - Returns the team member's name with a ``@``. + Returns the team member's handle (e.g. ``@user`` or ``user#discriminator``). .. versionadded:: 1.3 @@ -121,7 +121,7 @@ class TeamMember(BaseUser): discriminator: :class:`str` The team member's discriminator. This is a legacy concept that is no longer used. global_name: Optional[:class:`str`] - The user's global nickname, taking precedence over the username in display. + The team member's global nickname, taking precedence over the username in display. .. versionadded:: 2.3 bot: :class:`bool` diff --git a/discord/user.py b/discord/user.py index 303a33ea6..6b3a041bb 100644 --- a/discord/user.py +++ b/discord/user.py @@ -99,7 +99,9 @@ class BaseUser(_UserTag): ) def __str__(self) -> str: - return f'@{self.name}' + if self.discriminator == '0': + return f'@{self.name}' + return f'{self.name}#{self.discriminator}' def __eq__(self, other: object) -> bool: return isinstance(other, _UserTag) and other.id == self.id @@ -317,7 +319,7 @@ class ClientUser(BaseUser): .. describe:: str(x) - Returns the user's name with a ``@``. + Returns the user's handle (e.g. ``@user`` or ``user#discriminator``). Attributes ----------- @@ -457,7 +459,7 @@ class User(BaseUser, discord.abc.Messageable): .. describe:: str(x) - Returns the user's name with a ``@``. + Returns the user's handle (e.g. ``@user`` or ``user#discriminator``). Attributes ----------- diff --git a/discord/widget.py b/discord/widget.py index b2289c2e8..268173585 100644 --- a/discord/widget.py +++ b/discord/widget.py @@ -121,7 +121,7 @@ class WidgetMember(BaseUser): .. describe:: str(x) - Returns the widget member's name with a ``@``. + Returns the widget member's handle (e.g. ``@user`` or ``user#discriminator``). Attributes -----------