Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AttributeError when comparing commands #2299

Merged
merged 11 commits into from Jan 24, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -209,6 +209,8 @@ These changes are available on the `master` branch, but have not yet been releas
([#2301](https://github.com/Pycord-Development/pycord/pull/2301))
- Fixed `AttributeError` caused by `command.cog` being `MISSING`.
([#2303](https://github.com/Pycord-Development/pycord/issues/2303))
- 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
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
Dorukyum marked this conversation as resolved.
Show resolved Hide resolved
)

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