-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Describe the bug.
When starting the bot with a command that has a scope as a param specified it results in a KeyError:
Could not prepare the client:
Traceback (most recent call last):
File "----/venv/lib/python3.10/site-packages/interactions/client/bot.py", line 404, in _ready
await self.__sync()
File "----/venv/lib/python3.10/site-packages/interactions/client/bot.py", line 621, in __sync
if _guild_command["name"] not in __check_guild_commands[_guild_id]:
KeyError: NoneList the steps.
- Create a bot:
ids = 8210301307------
bot = interactions.Client(token="", default_scope=ids)- Create a command with a scope param:
@bot.command(
name="test",
description="test",
scope=ids
)
async def _test(ctx):
await ctx.send("test")- run the bot
- see Traceback
What you expected.
The command should be correctly registered for the guilds provided in the default_scope and command scope
File client/bot.py, line 517, in __resolve_commands:
if cmd.default_scope and self._default_scope:
cmd.scope = (
cmd.scope.extend(self._default_scope)
if isinstance(cmd.scope, list)
else self._default_scope
)cmd.scope.extend(self._default_scope)
extends the cmd.scope, but then sets cmd.scope to its return value, which is None.
This overrides the scope, resulting in None being passed as the scope to command in full_data.
This passes None as the guild_id to the ApplicationCommand, which is used in when getting a guild_commands _guild_id
=> KeyError here if _guild_command["name"] not in __check_guild_commands[_guild_id]:
replace
if cmd.default_scope and self._default_scope:
cmd.scope = (
cmd.scope.extend(self._default_scope)
if isinstance(cmd.scope, list)
else self._default_scope
)with
if cmd.default_scope and self._default_scope:
if isinstance(cmd.scope, list):
cmd.scope.extend(self._default_scope)
else:
cmd.scope = self._default_scopeWhat you saw.
Instead, I received this traceback error given from my Python terminal:
Could not prepare the client:
Traceback (most recent call last):
File "----/venv/lib/python3.10/site-packages/interactions/client/bot.py", line 404, in _ready
await self.__sync()
File "----/venv/lib/python3.10/site-packages/interactions/client/bot.py", line 621, in __sync
if _guild_command["name"] not in __check_guild_commands[_guild_id]:
KeyError: NoneWhat version of the library did you use?
stable
Version specification
4.3.4
Code of Conduct
- I agree to follow the contribution requirements.