Skip to content

Commit 33d6543

Browse files
fix: AttributeError when comparing commands (Pycord-Development#2299)
* fix: ApplicationCommand.__eq__ * style(pre-commit): auto fixes from pre-commit.com hooks * docs: changelog * style(pre-commit): auto fixes from pre-commit.com hooks * refactor: only check qualified name and guild_ids * style(pre-commit): auto fixes from pre-commit.com hooks * chore: update changelog --------- Signed-off-by: Dorukyum <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2f3084e commit 33d6543

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ These changes are available on the `master` branch, but have not yet been releas
211211
([#2303](https://github.com/Pycord-Development/pycord/issues/2303))
212212
- Fixed `self.use_default_buttons` being assumed truthy by `Paginator.update`.
213213
([#2319](https://github.com/Pycord-Development/pycord/pull/2319))
214+
- Fixed `AttributeError` when comparing application commands with non-command objects.
215+
([#2299](https://github.com/Pycord-Development/pycord/issues/2299))
214216

215217
## [2.4.1] - 2023-03-20
216218

discord/commands/core.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -235,15 +235,10 @@ def __repr__(self) -> str:
235235
return f"<discord.commands.{self.__class__.__name__} name={self.name}>"
236236

237237
def __eq__(self, other) -> bool:
238-
if (
239-
getattr(self, "id", None) is not None
240-
and getattr(other, "id", None) is not None
241-
):
242-
check = self.id == other.id
243-
else:
244-
check = self.name == other.name and self.guild_ids == other.guild_ids
245238
return (
246-
isinstance(other, self.__class__) and self.parent == other.parent and check
239+
isinstance(other, self.__class__)
240+
and self.qualified_name == other.qualified_name
241+
and self.guild_ids == other.guild_ids
247242
)
248243

249244
async def __call__(self, ctx, *args, **kwargs):

0 commit comments

Comments
 (0)