Skip to content

Commit e391c82

Browse files
fix: command syncing edge cases (#2797)
* change default nsfw to false * cl * localizations * := * style(pre-commit): auto fixes from pre-commit.com hooks --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent a5b70e6 commit e391c82

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ These changes are available on the `master` branch, but have not yet been releas
128128
changes. ([#2671](https://github.com/Pycord-Development/pycord/pull/2671))
129129
- `Entitlement.ends_at` can now be `None`.
130130
([#2564](https://github.com/Pycord-Development/pycord/pull/2564))
131+
- Changed the default value of `ApplicationCommand.nsfw` to `False`.
132+
([#2797](https://github.com/Pycord-Development/pycord/pull/2797))
131133

132134
### Deprecated
133135

discord/bot.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -328,12 +328,17 @@ def _check_command(cmd: ApplicationCommand, match: Mapping[str, Any]) -> bool:
328328
]:
329329
# We have a difference
330330
return True
331-
elif getattr(cmd, check, None) != match.get(check):
332-
# We have a difference
333-
if (
331+
elif (attr := getattr(cmd, check, None)) != (
332+
found := match.get(check)
333+
):
334+
# We might have a difference
335+
if "localizations" in check and bool(attr) == bool(found):
336+
# unlike other attrs, localizations are MISSING by default
337+
continue
338+
elif (
334339
check == "default_permission"
335-
and getattr(cmd, check) is True
336-
and match.get(check) is None
340+
and attr is True
341+
and found is None
337342
):
338343
# This is a special case
339344
# TODO: Remove for perms v2

discord/commands/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def __init__(self, func: Callable, **kwargs) -> None:
233233
"__default_member_permissions__",
234234
kwargs.get("default_member_permissions", None),
235235
)
236-
self.nsfw: bool | None = getattr(func, "__nsfw__", kwargs.get("nsfw", None))
236+
self.nsfw: bool | None = getattr(func, "__nsfw__", kwargs.get("nsfw", False))
237237

238238
integration_types = getattr(
239239
func, "__integration_types__", kwargs.get("integration_types", None)
@@ -1255,7 +1255,7 @@ def __init__(
12551255
self.default_member_permissions: Permissions | None = kwargs.get(
12561256
"default_member_permissions", None
12571257
)
1258-
self.nsfw: bool | None = kwargs.get("nsfw", None)
1258+
self.nsfw: bool | None = kwargs.get("nsfw", False)
12591259

12601260
integration_types = kwargs.get("integration_types", None)
12611261
contexts = kwargs.get("contexts", None)

0 commit comments

Comments
 (0)