Skip to content

Commit fc7b104

Browse files
fix: change default attribute of SlashCommandGroup (Pycord-Development#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 <[email protected]> Co-authored-by: Dorukyum <[email protected]>
1 parent 8af8454 commit fc7b104

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ These changes are available on the `master` branch, but have not yet been releas
205205
([#2295](https://github.com/Pycord-Development/pycord/issues/2295))
206206
- Fixed `AttributeError` when failing to establish initial websocket connection.
207207
([#2301](https://github.com/Pycord-Development/pycord/pull/2301))
208+
- Fixed `AttributeError` caused by `command.cog` being `MISSING`.
209+
([#2303](https://github.com/Pycord-Development/pycord/issues/2303))
208210

209211
## [2.4.1] - 2023-03-20
210212

discord/commands/core.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,7 @@ def _is_typing_annotated(self, annotation):
846846

847847
@property
848848
def cog(self):
849-
return getattr(self, "_cog", MISSING)
849+
return getattr(self, "_cog", None)
850850

851851
@cog.setter
852852
def cog(self, val):
@@ -1162,7 +1162,7 @@ def __init__(
11621162

11631163
self._before_invoke = None
11641164
self._after_invoke = None
1165-
self.cog = MISSING
1165+
self.cog = None
11661166
self.id = None
11671167

11681168
# Permissions
@@ -1238,10 +1238,7 @@ def to_dict(self) -> dict:
12381238
return as_dict
12391239

12401240
def add_command(self, command: SlashCommand) -> None:
1241-
# check if subcommand has no cog set
1242-
# also check if cog is MISSING because it
1243-
# might not have been set by the cog yet
1244-
if command.cog is MISSING and self.cog is not MISSING:
1241+
if command.cog is None and self.cog is not None:
12451242
command.cog = self.cog
12461243

12471244
self.subcommands.append(command)

0 commit comments

Comments
 (0)