Skip to content

Commit a95e2b7

Browse files
GeomKidFayeDelDamego
authored
fix: The issue of multiple client unable to load the commands from the same extension (#1134)
* fix the multiple client mode * Update bot.py * Remove some IDE format accident * fix: sys.module deleting modules twice * Update interactions/client/bot.py Co-authored-by: Damego <[email protected]> Co-authored-by: DeltaX <[email protected]> Co-authored-by: Damego <[email protected]>
1 parent aecb101 commit a95e2b7

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

interactions/client/bot.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def __resolve_commands(self) -> None:
535535
This is an internal method. Do not call it unless you know what you are doing!
536536
"""
537537
for cmd in self._commands:
538-
if cmd.resolved:
538+
if cmd.coro.__qualname__ in [_cmd.__qualname__ for _cmd in self.__command_coroutines]:
539539
continue
540540

541541
cmd.listener = self._websocket._dispatch
@@ -581,7 +581,6 @@ def __resolve_commands(self) -> None:
581581
self._scopes.add(cmd.scope if isinstance(cmd.scope, int) else cmd.scope.id)
582582

583583
self.event(coro, name=f"command_{cmd.name}")
584-
cmd.resolved = True
585584

586585
async def __sync(self) -> None: # sourcery no-metrics
587586
"""
@@ -1413,6 +1412,7 @@ def load(
14131412
else:
14141413
log.debug(f"Loaded extension {name}.")
14151414
self._extensions[_name] = module
1415+
del sys.modules[name]
14161416
return extension
14171417

14181418
def remove(
@@ -1450,7 +1450,6 @@ def remove(
14501450
self._loop.create_task(
14511451
_extension.teardown(remove_commands=remove_commands)
14521452
) # made for Extension, usable by others
1453-
del sys.modules[_name]
14541453

14551454
else:
14561455
with contextlib.suppress(AttributeError):

interactions/client/models/command.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ class Command(DictSerializerMixin):
411411
:ivar Dict[str, int] num_options: The dictionary of the number of options per subcommand.
412412
:ivar Dict[str, Union[Callable[..., Awaitable], str]] autocompletions: The dictionary of autocompletions for the command.
413413
:ivar Optional[str] recent_group: The name of the group most recently utilized.
414-
:ivar bool resolved: Whether the command is synced. Defaults to ``False``.
415414
:ivar Optional[Extension] extension: The extension that the command belongs to, if any.
416415
:ivar Client client: The client that the command belongs to.
417416
:ivar Optional[Listener] listener: The listener, used for dispatching command errors.
@@ -436,7 +435,6 @@ class Command(DictSerializerMixin):
436435
)
437436
recent_group: Optional[str] = field(default=None, init=False)
438437
error_callback: Optional[Callable[..., Awaitable]] = field(default=None, init=False)
439-
resolved: bool = field(default=False, init=False)
440438
extension: Optional["Extension"] = field(default=None, init=False)
441439
client: "Client" = field(default=None, init=False)
442440
listener: Optional["Listener"] = field(default=None, init=False)

0 commit comments

Comments
 (0)