【问题标题】:DIscord Slash Commands Interaction Failed on discord pyDIScord斜线命令交互在discord py上失败
【发布时间】:2021-11-12 12:55:45
【问题描述】:
async def _ping(ctx):  # Defines a new "context" (ctx) command called "ping."
    async def command_hi(ctx):
        await ctx.defer()
        await ctx.send("Pong!")
        pass

我正在制作斜杠命令,第一次它工作但第二次,它不起作用。 我试过 await ctx.defer() 但它也不起作用

【问题讨论】:

  • 你能告诉我们更多信息吗?请提供更多代码!

标签: discord discord.py


【解决方案1】:

嘿@Justnoob 我建议你使用 Pycord,它有内置的按钮、斜线、下拉菜单等等,但是现在带有应用程序命令的不和谐 api 有点复杂,我们通常使用 ctx.send 但在应用程序命令中它是 @ 987654322@ 所以这里是代码:-

async def ping(ctx): #Don't use _ping too.
await ctx.respond("Pong!")

我仍然不明白你为什么在一个命令中创建了两个 async def。应该只有一个,并且您已经指定了它。

【讨论】:

  • 顺便说一句,我删除了 await ctx.defer() 并通过了它,它起作用了。谢谢你的回应 btw
  • 不用谢。
猜你喜欢
  • 2021-12-31
  • 2021-10-19
  • 2021-06-06
  • 1970-01-01
  • 2023-03-17
  • 2021-05-09
  • 2021-10-06
  • 2021-11-20
  • 1970-01-01
相关资源
最近更新 更多