From fc7b1042c4a9a942b9996dfe96f56aac059e179c Mon Sep 17 00:00:00 2001 From: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Date: Wed, 3 Jan 2024 16:53:06 +0000 Subject: [PATCH] fix: change default attribute of `SlashCommandGroup` (#2303) * Update core.py and changelog * Update core.py * Update core.py * Update core.py * chore: update changelog * fix: remove all references to cog being MISSING --------- Signed-off-by: Dasupergrasskakjd <106623583+Dasupergrasskakjd@users.noreply.github.com> Co-authored-by: Dorukyum --- CHANGELOG.md | 2 ++ discord/commands/core.py | 9 +++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8878fadad..fea137c75a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -205,6 +205,8 @@ These changes are available on the `master` branch, but have not yet been releas ([#2295](https://github.com/Pycord-Development/pycord/issues/2295)) - Fixed `AttributeError` when failing to establish initial websocket connection. ([#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)) ## [2.4.1] - 2023-03-20 diff --git a/discord/commands/core.py b/discord/commands/core.py index c7bd4efd40..aff52c8108 100644 --- a/discord/commands/core.py +++ b/discord/commands/core.py @@ -846,7 +846,7 @@ def _is_typing_annotated(self, annotation): @property def cog(self): - return getattr(self, "_cog", MISSING) + return getattr(self, "_cog", None) @cog.setter def cog(self, val): @@ -1162,7 +1162,7 @@ def __init__( self._before_invoke = None self._after_invoke = None - self.cog = MISSING + self.cog = None self.id = None # Permissions @@ -1238,10 +1238,7 @@ def to_dict(self) -> dict: return as_dict def add_command(self, command: SlashCommand) -> None: - # check if subcommand has no cog set - # also check if cog is MISSING because it - # might not have been set by the cog yet - if command.cog is MISSING and self.cog is not MISSING: + if command.cog is None and self.cog is not None: command.cog = self.cog self.subcommands.append(command)