我正在使用 Discord.py 2.3.2 和 Interactions API 编写一个 Discord 机器人。运行我的代码片段时:
@commands.hybrid_command(name='help', with_app_command=True)
async def help(self, ctx: commands.Context):
await ctx.reply("Test was good!")
我收到错误
line 65, in <module>
async def help(self, ctx: commands.Context):
TypeError: unsupported type annotation <class 'discord.ext.commands.context.Context'>
造成这种情况的原因是什么以及我应该如何解决它?
我已尽力遵循 Interactions API 文档,但无济于事。我收到的错误位于直接从文档示例复制的行中。我的命令
@bot.tree.command()
async def test(interaction: discord.Interaction) -> None:
await interaction.response.send_message("test successful")
工作得很好,但混合命令不行。