使用 interaction.response.defer() [Nextcord] 后无法响应交互
Can't respond to Interaction after using interaction.response.defer() [Nextcord]
我有一个斜线命令,但它需要几秒钟的时间来处理。由于 Discord 响应交互的限制似乎是 3 秒,我在文档中找到了 interaction.response.defer() 方法,它应该告诉 Discord 我已经收到命令(而不是抛出错误“交互没有响应”。 )
@client.slash_command(description="Test command", guild_ids=[123456789123456789])
async def test(interaction: nextcord.Interaction):
await interaction.response.defer()
await asyncio.sleep(10) # Doing stuff
await interaction.response.send_message("My actual content")
但是我得到这个错误:
nextcord.errors.InteractionResponded: This interaction has already been responded to before
我做错了什么?
应使用 interaction.followup.send()
而不是 send_message()
我有一个斜线命令,但它需要几秒钟的时间来处理。由于 Discord 响应交互的限制似乎是 3 秒,我在文档中找到了 interaction.response.defer() 方法,它应该告诉 Discord 我已经收到命令(而不是抛出错误“交互没有响应”。 )
@client.slash_command(description="Test command", guild_ids=[123456789123456789])
async def test(interaction: nextcord.Interaction):
await interaction.response.defer()
await asyncio.sleep(10) # Doing stuff
await interaction.response.send_message("My actual content")
但是我得到这个错误:
nextcord.errors.InteractionResponded: This interaction has already been responded to before
我做错了什么?
interaction.followup.send()
而不是 send_message()