【问题标题】:discord ping command (Python)不和谐 ping 命令(Python)
【发布时间】:2025-12-28 05:35:11
【问题描述】:

这是我当前的 ping 命令代码:

async def ping(ctx):
  await ctx.send(f"Pong! ???? \nLatency: **{round(client.latency * 1000)}ms**")

但我想变成这样:

我该怎么做?

编辑:好吧,不是嵌入,而是嵌入中的内容,例如响应时间等。

【问题讨论】:

    标签: python discord discord.py


    【解决方案1】:

    这称为富嵌入。

    见:How can I send an embed via my Discord bot, w/python?

    TLDR:

    async def ping(ctx):
        embedVar = discord.Embed(title="Pong", description="Pong", color=0x00ff00)
        embedVar.add_field(name="Latency", value=str(round(client.latency * 1000)), inline=False)
        await ctx.send(embed=embedVar)
    

    【讨论】:

      【解决方案2】:

      就像 testfile 已经说过的那样。

      你必须使用不和谐的嵌入

      首先,您可以使用生成器。生成器生成输入预览和 python 代码示例。 这应该对您有所帮助。

      https://cog-creators.github.io/discord-embed-sandbox/

      【讨论】: