Skip to content
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ These changes are available on the `master` branch, but have not yet been releas
listeners. ([#2044](https://github.com/Pycord-Development/pycord/pull/2044))
- Fixed unloading of cogs having bridge commands.
([#2048](https://github.com/Pycord-Development/pycord/pull/2048))
- Fixed the Slash command syncronization method `indiviual`.
([#1925](https://github.com/Pycord-Development/pycord/pull/1925))

## [2.4.1] - 2023-03-20

Expand Down
37 changes: 28 additions & 9 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,21 +501,24 @@ def _register(
)

def register(
method: Literal["bulk", "upsert", "delete", "edit"], *args, **kwargs
method: Literal["bulk", "upsert", "delete", "edit"],
*args,
cmd_name: str = None,
guild_id: int | None = None,
**kwargs,
):
if kwargs.pop("_log", True):
if method == "bulk":
_log.debug(
f"Bulk updating commands {[c['name'] for c in args[0]]} for"
f" guild {guild_id}"
)
# TODO: Find where "cmd" is defined
elif method == "upsert":
_log.debug(f"Creating command {cmd['name']} for guild {guild_id}") # type: ignore
_log.debug(f"Creating command {cmd_name} for guild {guild_id}") # type: ignore
elif method == "edit":
_log.debug(f"Editing command {cmd['name']} for guild {guild_id}") # type: ignore
_log.debug(f"Editing command {cmd_name} for guild {guild_id}") # type: ignore
elif method == "delete":
_log.debug(f"Deleting command {cmd['name']} for guild {guild_id}") # type: ignore
_log.debug(f"Deleting command {cmd_name} for guild {guild_id}") # type: ignore
return _register(method, *args, **kwargs)

pending_actions = []
Expand Down Expand Up @@ -602,15 +605,31 @@ def register(
registered = []
for cmd in filtered_no_action:
if cmd["action"] == "delete":
await register("delete", cmd["command"])
await register(
"delete",
cmd["id"],
cmd_name=cmd["command"].name,
guild_id=guild_id,
)
continue
if cmd["action"] == "edit":
registered.append(
await register("edit", cmd["id"], cmd["command"].to_dict())
await register(
"edit",
cmd["id"],
cmd["command"].to_dict(),
cmd_name=cmd["command"].name,
guild_id=guild_id,
)
)
elif cmd["action"] == "upsert":
registered.append(
await register("upsert", cmd["command"].to_dict())
await register(
"upsert",
cmd["command"].to_dict(),
cmd_name=cmd["command"].name,
guild_id=guild_id,
)
)
else:
raise ValueError(f"Unknown action: {cmd['action']}")
Expand All @@ -628,7 +647,7 @@ def register(
)
else:
data = [cmd.to_dict() for cmd in pending]
registered = await register("bulk", data)
registered = await register("bulk", data, guild_id=guild_id)

for i in registered:
cmd = get(
Expand Down