【发布时间】:2021-09-22 13:46:36
【问题描述】:
我有一个长时间运行的函数,大约需要 20 秒左右才能完成。函数完成后,会将结果作为消息发送给 Discord。
如果我通过输入常规命令(没有斜杠命令)来运行此功能,它完全可以正常工作,并且我会看到发送到 Discord 的结果。
但是,如果我通过斜杠命令调用该函数,Discord 会告诉我“此交互失败”,然后在我看到消息中的结果后不久。所以这个函数工作得很好,但是斜杠命令似乎被认为是失败了。
为了测试这个,我得到了一个基本函数:
@slash.slash(name="test",
guild_ids=[123,456],
description="This is just a test command, nothing more.",
options=[
create_option(
name="optone",
description="This is the first option we have.",
option_type=3,
required=False
)
])
async def test(ctx, optone: str):
await ctx.send(content=f"I got you, you said {optone}!")
如果我通过斜杠命令调用它,没问题。然后我在await ctx.send... 上放置一个断点并再次运行该命令。 Discord 说“此交互失败”。我继续调试执行,然后发送消息。
为什么斜杠命令会认为命令失败,什么时候没有,我该如何解决这个问题?
【问题讨论】:
标签: python discord discord.py