From bd402dc4ca00af0435679d0c52100f19414ac760 Mon Sep 17 00:00:00 2001 From: GeomKid <51281740+GeomKid@users.noreply.github.com> Date: Wed, 26 Oct 2022 14:51:41 +0800 Subject: [PATCH 1/5] fix the multiple client mode --- interactions/client/bot.py | 3 +-- interactions/client/models/command.py | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/interactions/client/bot.py b/interactions/client/bot.py index 480ba068e..259ed98a3 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -509,7 +509,7 @@ def __resolve_commands(self) -> None: This is an internal method. Do not call it unless you know what you are doing! """ for cmd in self._commands: - if cmd.resolved: + if cmd.coro.__qualname__ in [Cmd.__qualname__ for Cmd in self.__command_coroutines]: continue cmd.listener = self._websocket._dispatch @@ -555,7 +555,6 @@ def __resolve_commands(self) -> None: self._scopes.add(cmd.scope if isinstance(cmd.scope, int) else cmd.scope.id) self.event(coro, name=f"command_{cmd.name}") - cmd.resolved = True async def __sync(self) -> None: # sourcery no-metrics """ diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index c92d3cabf..9264cb96b 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -411,7 +411,6 @@ class Command(DictSerializerMixin): :ivar Dict[str, int] num_options: The dictionary of the number of options per subcommand. :ivar Dict[str, Union[Callable[..., Awaitable], str]] autocompletions: The dictionary of autocompletions for the command. :ivar Optional[str] recent_group: The name of the group most recently utilized. - :ivar bool resolved: Whether the command is synced. Defaults to ``False``. :ivar Optional[Extension] extension: The extension that the command belongs to, if any. :ivar Client client: The client that the command belongs to. :ivar Optional[Listener] listener: The listener, used for dispatching command errors. @@ -436,7 +435,6 @@ class Command(DictSerializerMixin): ) recent_group: Optional[str] = field(default=None, init=False) error_callback: Optional[Callable[..., Awaitable]] = field(default=None, init=False) - resolved: bool = field(default=False, init=False) extension: Optional["Extension"] = field(default=None, init=False) client: "Client" = field(default=None, init=False) listener: Optional["Listener"] = field(default=None, init=False) @@ -862,7 +860,8 @@ async def __call( if has_args: # foo(ctx, ..., *args, ..., **kwargs) OR foo(ctx, *args, ...) return await _coro( ctx, - *(kwargs[opt] for opt in par_opts if opt in kwargs), # pos before *args + # pos before *args + *(kwargs[opt] for opt in par_opts if opt in kwargs), *args, *( kwargs[opt] From cdf2c1aab913120278f19652f34ebc4bb952a93f Mon Sep 17 00:00:00 2001 From: GeomKid <51281740+GeomKid@users.noreply.github.com> Date: Mon, 31 Oct 2022 12:59:22 +0800 Subject: [PATCH 2/5] Update bot.py --- interactions/client/bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/interactions/client/bot.py b/interactions/client/bot.py index 259ed98a3..001ab70ac 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -1386,6 +1386,7 @@ def load( else: log.debug(f"Loaded extension {name}.") self._extensions[_name] = module + del sys.modules[name] return extension def remove( From 57b895d07680d6843dc6928fd854a81155714aca Mon Sep 17 00:00:00 2001 From: GeomKid <51281740+GeomKid@users.noreply.github.com> Date: Mon, 31 Oct 2022 21:07:20 +0800 Subject: [PATCH 3/5] Remove some IDE format accident --- interactions/client/models/command.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/interactions/client/models/command.py b/interactions/client/models/command.py index 9264cb96b..5f486c13f 100644 --- a/interactions/client/models/command.py +++ b/interactions/client/models/command.py @@ -860,8 +860,7 @@ async def __call( if has_args: # foo(ctx, ..., *args, ..., **kwargs) OR foo(ctx, *args, ...) return await _coro( ctx, - # pos before *args - *(kwargs[opt] for opt in par_opts if opt in kwargs), + *(kwargs[opt] for opt in par_opts if opt in kwargs), # pos before *args *args, *( kwargs[opt] From f49b2c07ade6a641880de74b1cac94c74e3e8746 Mon Sep 17 00:00:00 2001 From: GeomKid <51281740+GeomKid@users.noreply.github.com> Date: Sat, 5 Nov 2022 01:49:59 +0800 Subject: [PATCH 4/5] fix: sys.module deleting modules twice --- interactions/client/bot.py | 1 - 1 file changed, 1 deletion(-) diff --git a/interactions/client/bot.py b/interactions/client/bot.py index 001ab70ac..13fc21336 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -1424,7 +1424,6 @@ def remove( self._loop.create_task( _extension.teardown(remove_commands=remove_commands) ) # made for Extension, usable by others - del sys.modules[_name] else: with contextlib.suppress(AttributeError): From bcb66ea061caf1895e86211f66dd9fe97a493501 Mon Sep 17 00:00:00 2001 From: GeomKid <51281740+GeomKid@users.noreply.github.com> Date: Sat, 5 Nov 2022 11:36:35 +0800 Subject: [PATCH 5/5] Update interactions/client/bot.py Co-authored-by: Damego --- interactions/client/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interactions/client/bot.py b/interactions/client/bot.py index 13fc21336..8a5aaab5a 100644 --- a/interactions/client/bot.py +++ b/interactions/client/bot.py @@ -509,7 +509,7 @@ def __resolve_commands(self) -> None: This is an internal method. Do not call it unless you know what you are doing! """ for cmd in self._commands: - if cmd.coro.__qualname__ in [Cmd.__qualname__ for Cmd in self.__command_coroutines]: + if cmd.coro.__qualname__ in [_cmd.__qualname__ for _cmd in self.__command_coroutines]: continue cmd.listener = self._websocket._dispatch