所以我试图通过python和discord编程ping命令。问题是,在尝试了一堆方法之后,我仍然不知道它是如何工作的。如果有人能帮助我,我将非常感激。
答案 0 :(得分:0)
如果你使用带有命令扩展名的discord.py重写,你可以bot.latency
返回一个浮点数。
答案 1 :(得分:0)
import discord
import time
from time import
time_then = time.monotonic()
pinger = await client.send_message(message.channel, '__*`Pinging...`*__')
ping = '%.2f' % (1000*(time.monotonic()-time_then))
await client.edit_message(pinger, ':ping_pong: \n **Pong!** __**`' + ping + 'ms`**__') # you can edit this to say whatever you want really. Hope this helps.