Latency command in Discord.py

Rufpi picture Rufpi · Sep 19, 2017 · Viewed 25.1k times · Source

I've looked in a lot of places and I can't find a way to make a ping (latency) command using discord.py, something like this:

@client.command(pass_context=True)
async def pong(ctx):
    # Somehow find 'pingtime'
    await client.say(pingtime)

Answer

mental picture mental · Jan 4, 2018

Really at this point you should be using the rewrite branch of discord.py

This would be my solution using the commands extension.

@bot.command()
async def ping(ctx):
    await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))