Skip to content

Commit

Permalink
fix: AttributeError when comparing commands (#2299)
Browse files Browse the repository at this point in the history
* 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 <53639936+Dorukyum@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Dorukyum and pre-commit-ci[bot] authored Jan 24, 2024
1 parent 2f3084e commit 33d6543
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2303](https://github.com/Pycord-Development/pycord/issues/2303))
- Fixed `self.use_default_buttons` being assumed truthy by `Paginator.update`.
([#2319](https://github.com/Pycord-Development/pycord/pull/2319))
- Fixed `AttributeError` when comparing application commands with non-command objects.
([#2299](https://github.com/Pycord-Development/pycord/issues/2299))

## [2.4.1] - 2023-03-20

Expand Down
11 changes: 3 additions & 8 deletions discord/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,10 @@ def __repr__(self) -> str:
return f"<discord.commands.{self.__class__.__name__} name={self.name}>"

def __eq__(self, other) -> bool:
if (
getattr(self, "id", None) is not None
and getattr(other, "id", None) is not None
):
check = self.id == other.id
else:
check = self.name == other.name and self.guild_ids == other.guild_ids
return (
isinstance(other, self.__class__) and self.parent == other.parent and check
isinstance(other, self.__class__)
and self.qualified_name == other.qualified_name
and self.guild_ids == other.guild_ids
)

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

0 comments on commit 33d6543

Please sign in to comment.