-
Notifications
You must be signed in to change notification settings - Fork 185
Description
Describe the bug.
I was trying to create a slash function that has two subcommands, which each take no options. However, when the slash command's subcommand is run, even though the subcommand is passed via JSON, it is not passed to the sub_command argument of the command function.
However, if the subcommand has an option, it works fine and both the subcommand and the option are passed to the command function.
function decorator of the command in question:
@bot.command(
name="opt",
description="Opts in or out of the Twitter starboard",
scope=575336474333937670,
options=[
interactions.Option(
name="in",
description="Opts in to the Twitter starboard",
type=interactions.OptionType.SUB_COMMAND,
options=[],
),
interactions.Option(
name="out",
description="Opts out of the Twitter starboard",
type=interactions.OptionType.SUB_COMMAND,
options=[],
),
],
)List the steps.
- Create a command that has a subcommand that takes no options
- Run the code and try to run the subcommand in a server.
What you expected.
The subcommand should have executed when run, which in this case, it is supposed to pull the first entry from a MariaDB database and send it into the channel.
What you saw.
On discord, after the command was run, the standard "this application did not respond" notice and the program exits with a non-zero exit code.
Instead, I received this traceback error given from my Python terminal:
Traceback (most recent call last):
File "/Users/-/Desktop/yes-yes-bot/main.py", line 106, in <module>
bot.start()
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/client.py", line 109, in start
self._loop.run_until_complete(self._ready())
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/client.py", line 307, in _ready
await self._login()
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/client.py", line 312, in _login
await self._websocket._establish_connection(self._shard, self._presence)
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/api/gateway.py", line 209, in _establish_connection
await self._handle_connection(stream, shard, presence)
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/api/gateway.py", line 277, in _handle_connection
self._dispatch_event(event, data)
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/api/gateway.py", line 381, in _dispatch_event
self._dispatch.dispatch(_name, *__args, **__kwargs)
File "/Users/-/.pyenv/versions/3.9.9/lib/python3.9/site-packages/interactions/api/dispatch.py", line 37, in dispatch
self.loop.create_task(event(*args, **kwargs))
TypeError: opt() missing 1 required positional argument: 'sub_command'
however, logging tells me that it was passed via JSON
[*fragment of the json*]
'data': {'type': 1, 'options': [{'type': 1, 'options': [], 'name': 'out'}], 'name': 'opt', 'id': '946668308533510145'}, 'channel_id': '694159911071776808', 'application_id': '946662687755091989'}
What version of the library did you use?
release
Code of Conduct
- I agree to follow the contribution requirements.