当我的机器人非常忙时,有时需要几秒钟才能响应斜杠命令。然而,在他回复之前,不和谐会发出“应用程序没有响应”的信息。我怎么能让争吵等得更久才能收到机器人的信息呢?
发布于 2022-02-28 16:45:37
你试过使用Interaction.defer()吗?下面是一个关于如何使用它的快速示例:
@bot_instance.slash_command(name="hi")
async def hi(ctx):
await ctx.defer()
# fairly long task?
await ctx.followup.send( # Whatever you want to send...有关更多信息,请查看API引用:https://docs.pycord.dev/en/master/api.html#discord.Interaction
还请参阅与此问题相关的GitHub问题:https://github.com/Pycord-Development/pycord/issues/264
发布于 2022-06-20 03:54:41
有一种叫做延迟的方法,您可以这样做来增加函数的等待时间。
@bot_instance.command(description="Description of the command"
async def command(ctx:discord.Interaction,keyword:str)#Keyword if any
await ctx.response.defer(ephemeral=True)#This line defers the function
#Do your process here
await ctx.followup("Followup message")#This is the confirmation messagehttps://stackoverflow.com/questions/71296971
复制相似问题