discord.py Ping命令

discord.py Ping命令,discord,discord.py,Discord,Discord.py,我的discord.py命令有问题。我想发出ping命令,该命令将以我的机器人的ping响应。我的代码如下 @bot.command() 异步定义ping(ctx): 等待ctx.send(f“Pong:ping_Pong:!Bot latency:*{round(Bot.latency*1000)}ms**” 我也试着这样写我的代码 @client.command() 异步定义ping(ctx): 等待ctx.send(f“Pong:ping_Pong:!Bot latency:*{roun

我的discord.py命令有问题。我想发出ping命令,该命令将以我的机器人的ping响应。我的代码如下

@bot.command()
异步定义ping(ctx):
等待ctx.send(f“Pong:ping_Pong:!Bot latency:*{round(Bot.latency*1000)}ms**”
我也试着这样写我的代码

@client.command()
异步定义ping(ctx):
等待ctx.send(f“Pong:ping_Pong:!Bot latency:*{round(Bot.latency*1000)}ms**”

上述代码都不起作用。

是否在末尾添加了括号

@bot.command() # set this to your bots variable
async def ping(ctx):
     await ctx.send(f"Ping!\nLatency is **{round(bot.latency * 1000)}ms**!")

我有这个命令,我已经测试过它,知道它是有效的。你可以试试它:

@bot.command()
async def ping(ctx):
    await ctx.send(f'My ping is** {round(bot.latency*1000)} Ms**')

顺便说一句,如果您已将bot定义为客户端,请确保将bot.latency更改为client.latency

您所说的“不工作”是什么意思。它是否打印错误?如果是,则发送错误,并且在两个代码块中都缺少关闭
。这是复制粘贴错误吗?