aboutsummaryrefslogtreecommitdiffstats
path: root/pydis_site/apps/api/models/bot
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-08-23 13:26:37 +0200
committerGravatar Sebastiaan Zeeff <[email protected]>2019-08-23 13:27:58 +0200
commit861f272ccf76abfe317b96827e4632b2657d5d69 (patch)
tree4b16184a4e8026cda2f5905a97e325219e24b261 /pydis_site/apps/api/models/bot
parentFirst adding default value, then removing it to make it required. (diff)
Making the comparison operators for Role act like those for d.py Role objects
Diffstat (limited to 'pydis_site/apps/api/models/bot')
-rw-r--r--pydis_site/apps/api/models/bot/role.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/pydis_site/apps/api/models/bot/role.py b/pydis_site/apps/api/models/bot/role.py
index 836d9f27..58bbf8b4 100644
--- a/pydis_site/apps/api/models/bot/role.py
+++ b/pydis_site/apps/api/models/bot/role.py
@@ -7,7 +7,12 @@ from pydis_site.apps.api.models.utils import ModelReprMixin
class Role(ModelReprMixin, models.Model):
- """A role on our Discord server."""
+ """
+ A role on our Discord server.
+
+ The comparison operators <, <=, >, >=, ==, != act the same as they do with Role-objects of the
+ discord.py library, see https://discordpy.readthedocs.io/en/latest/api.html#discord.Role
+ """
id = models.BigIntegerField(
primary_key=True,
@@ -49,10 +54,14 @@ class Role(ModelReprMixin, models.Model):
help_text="The position of the role in the role hierarchy of the Discord Guild."
)
- def __str__(self):
+ def __str__(self) -> str:
"""Returns the name of the current role, for display purposes."""
return self.name
- def __lt__(self, other: Role):
+ def __lt__(self, other: Role) -> bool:
"""Compares the roles based on their position in the role hierarchy of the guild."""
return self.position < other.position
+
+ def __le__(self, other: Role) -> bool:
+ """Compares the roles based on their position in the role hierarchy of the guild."""
+ return self.position <= other.position