From 615a24aa20cee883deb6e6ca58775f4933ed815a Mon Sep 17 00:00:00 2001 From: Catalyst4 <84055084+Catalyst4222@users.noreply.github.com> Date: Sun, 13 Mar 2022 18:45:43 -0400 Subject: [PATCH 1/2] feat: add `__eq__` to Snowflake --- interactions/api/models/misc.py | 10 ++++++++++ interactions/api/models/misc.pyi | 1 + 2 files changed, 11 insertions(+) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index 3a92110f0..b7edd45e3 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -166,6 +166,16 @@ def timestamp(self) -> datetime.datetime: def __hash__(self): return hash(self._snowflake) + def __eq__(self, other): + if isinstance(other, Snowflake): + return str(self) == str(other) + elif isinstance(other, int): + return int(self) == other + elif isinstance(other, str): + return str(self) == other + + return NotImplemented + # Do we need not equals, equals, gt/lt/ge/le? # If so, list them under. By Discord API this may not be needed # but end users might. diff --git a/interactions/api/models/misc.pyi b/interactions/api/models/misc.pyi index 73613fd44..9a319f427 100644 --- a/interactions/api/models/misc.pyi +++ b/interactions/api/models/misc.pyi @@ -42,6 +42,7 @@ class Snowflake(object): def __hash__(self) -> int: ... def __str__(self) -> str: ... def __int__(self) -> int: ... + def __eq__(self, other) -> Union[bool, NotImplemented]: ... class Format: USER: str From 1854c4186ae44c1173cf3c28c30b5cbe8df2d8eb Mon Sep 17 00:00:00 2001 From: Catalyst4 <84055084+Catalyst4222@users.noreply.github.com> Date: Sun, 13 Mar 2022 19:39:24 -0400 Subject: [PATCH 2/2] chore: remove outdated comments --- interactions/api/models/misc.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/interactions/api/models/misc.py b/interactions/api/models/misc.py index b7edd45e3..e2a6371b0 100644 --- a/interactions/api/models/misc.py +++ b/interactions/api/models/misc.py @@ -176,10 +176,6 @@ def __eq__(self, other): return NotImplemented - # Do we need not equals, equals, gt/lt/ge/le? - # If so, list them under. By Discord API this may not be needed - # but end users might. - class Color(object): """