NextCord:在斜杠命令中使用转换器出错



我有discord.py和pycord的背景,我决定尝试nextcord斜杠命令所以我决定创建一些命令,在这个命令中我得到了一个奇怪的错误消息

@slash_command(name='suggestions_set', guild_ids=[956174862815199252])
async def suggestions_set(self, interaction: Interaction, channel: TextChannel):
db.insert({'channel': channel.id})
await interaction.send(f'**The suggestions channel has been set to {channel.mention}**')

我得到了以下错误:

Traceback (most recent call last):
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordextcommandsbot.py", line 675, in _load_from_module_spec
spec.loader.exec_module(lib)  # type: ignore
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "C:UsersangelCodePythonspybotcogsinfo.py", line 6, in <module>
class Info(Cog):
File "C:UsersangelCodePythonspybotcogsinfo.py", line 10, in Info
async def suggestions_set(self, interaction: Interaction, channel: SlashOption):
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 1981, in decorator
app_cmd = ApplicationCommand(
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 1418, in __init__
super().__init__(
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 602, in __init__
self._from_callback(callback)
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 820, in _from_callback
arg = CommandOption(param, self)
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 327, in __init__
self.type: ApplicationCommandOptionType = self.get_type(parameter.annotation)
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordapplication_command.py", line 384, in get_type
raise NotImplementedError(
NotImplementedError: Type "<class 'nextcord.application_command.SlashOption'>" isn't a supported typing for Application Commands.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersangelCodePythonspybotbot.py", line 19, in <module>
bot.load_extension(f'cogs.{file[:-3]}')
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordextcommandsbot.py", line 789, in load_extension
self._load_from_module_spec(spec, name, extras=extras)
File "C:Usersangelanaconda3envsspybotlibsite-packagesnextcordextcommandsbot.py", line 678, in _load_from_module_spec
raise errors.ExtensionFailed(key, e) from e
nextcord.ext.commands.errors.ExtensionFailed: Extension 'cogs.info' raised an error: NotImplementedError: Type "<class 'nextcord.application_command.SlashOption'>" isn't a supported typing for Application Commands.

我明白这一定是一些类型的实现错误,但我不明白它,如果有人能告诉我做错了什么?

channel: TextChannel = SlashOption(...)应该根据其github存储库中的示例工作。

最新更新