简体   繁体   English

Pycord Slash 命令响应嵌入

[英]Pycord Slash command Respond with Embed

I have the following Pycord slash command我有以下 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)

When running the slash command with 'title' set to "test", I see the respone "hi" from the bot.在将“标题”设置为“测试”的情况下运行斜杠命令时,我看到机器人的响应“hi”。 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?是否可以用嵌入来响应斜杠命令?

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.我不是 100% 确定这是否是答案,但问题似乎是我实际上有 2 个机器人使用相同的“令牌”和斜杠命令运行。 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也许这是削减命令的一个缺点,只有一个运行的机器人才能真正处理它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM