【发布时间】:2017-11-18 22:36:06
【问题描述】:
所以我正在尝试通过 python 和 discord 编写一个 ping 命令。问题是,在尝试了一堆方法之后,我仍然不知道它是如何工作的。如果有人可以帮助我,我将非常感激。
【问题讨论】:
标签: python-3.x discord.py
所以我正在尝试通过 python 和 discord 编写一个 ping 命令。问题是,在尝试了一堆方法之后,我仍然不知道它是如何工作的。如果有人可以帮助我,我将非常感激。
【问题讨论】:
标签: python-3.x discord.py
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.
【讨论】:
如果您使用带有命令扩展名的 discord.py 重写,您可以 bot.latency 返回一个浮点数。
【讨论】: