Pycord Slash 命令通过嵌入进行响应
我有以下 Pycord 斜杠命令
@commands.slash_command(name="testcmd")
@commands.has_permissions(administrator=True)
async def SampleSlashComand(self, ctx: commands.Context,
title: Option(str, "title", required=True),
description: Option(str, "description", required=True),
):
await ctx.defer()
if title == "test":
return await ctx.respond("hi")
embed = discord.Embed(
title=f"{title}",
description=f"{description}",
timestamp=datetime.now()
)
return await ctx.respond(embed=embed)
当运行“标题”设置为“测试”的斜杠命令时,我看到机器人的响应“hi”。但是,当我使用另一个标题(导致发布嵌入)时,机器人会响应错误“交互应用程序命令无效”
是否可以通过嵌入响应斜杠命令?
I have the following Pycord slash command
@commands.slash_command(name="testcmd")
@commands.has_permissions(administrator=True)
async def SampleSlashComand(self, ctx: commands.Context,
title: Option(str, "title", required=True),
description: Option(str, "description", required=True),
):
await ctx.defer()
if title == "test":
return await ctx.respond("hi")
embed = discord.Embed(
title=f"{title}",
description=f"{description}",
timestamp=datetime.now()
)
return await ctx.respond(embed=embed)
When running the slash command with 'title' set to "test", I see the respone "hi" from the bot. However when I use another title, which causes an embedding to be posted, the bot responds with the error "Invalid interaction application command"
Is it possible to have a slash command be responded with a embedding?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 100% 确定这是否是答案,但问题似乎是我实际上有 2 个机器人使用相同的“令牌”和斜杠命令运行。自从我意识到并关闭重复的机器人后,一切都按预期工作,这似乎搞砸了一些事情。
也许这是斜线命令的一个缺点,只有一个正在运行的机器人才能真正处理它
Im not 100% sure if this is the answer or not but it appears the issue was that I actually had 2 bots running with the same "token" and slash command. This seems to have messed something up since when I realized and shutdown the duplicate bot everything worked as expected.
Maybe this is the one downside to slash commands, only one bot running can really handle it