Search code examples
pythondiscorddiscord.py

Latency command in Discord.py


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)

Solution

  • 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)))