diff --git a/pydis_site/apps/api/models/bot/user.py b/pydis_site/apps/api/models/bot/user.py index 4d317b8e1..15e83b2f6 100644 --- a/pydis_site/apps/api/models/bot/user.py +++ b/pydis_site/apps/api/models/bot/user.py @@ -76,7 +76,9 @@ class User(ModelReprMixin, models.Model): def __str__(self): """Returns the name and discriminator for the current user, for display purposes.""" - return f"{self.name}#{self.discriminator:04d}" + if self.discriminator: + return f"{self.name}#{self.discriminator:04d}" + return self.name @property def top_role(self) -> Role: diff --git a/pydis_site/apps/api/tests/test_models.py b/pydis_site/apps/api/tests/test_models.py index 456ac4085..0804384cf 100644 --- a/pydis_site/apps/api/tests/test_models.py +++ b/pydis_site/apps/api/tests/test_models.py @@ -187,3 +187,9 @@ def test_nomination_str_representation(self): "Nomination of Hemlock's Cat#7777 (active)", str(self.nomination) ) + + +class UserTests(SimpleTestCase): + def test_str_without_discriminator(self) -> None: + user = User(name="lemonfannumber1") + self.assertEqual(str(user), "lemonfannumber1")