【问题标题】:Discord python How to programm a ping commandDiscord python 如何编写 ping 命令
【发布时间】:2017-11-18 22:36:06
【问题描述】:

所以我正在尝试通过 python 和 discord 编写一个 ping 命令。问题是,在尝试了一堆方法之后,我仍然不知道它是如何工作的。如果有人可以帮助我,我将非常感激。

【问题讨论】:

    标签: python-3.x discord.py


    【解决方案1】:
    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.
    

    【讨论】:

      【解决方案2】:

      如果您使用带有命令扩展名的 discord.py 重写,您可以 bot.latency 返回一个浮点数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-08-25
        • 2022-01-04
        • 1970-01-01
        • 2021-10-11
        • 2020-10-13
        • 1970-01-01
        • 1970-01-01
        • 2020-11-26
        相关资源
        最近更新 更多