Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)
like image 373
Rufpi Avatar asked Sep 19 '17 18:09

Rufpi


People also ask

How do you make a discord.py Bot wait?

How do you make a Discord bot wait for a response in Python? python discord bot wait for response # Use Client. wait_for to wait for on_message event.

Is discord.py being discontinued?

According to the maintainer, Discord has told that the bots will continue to work fine even after April 2022.

Does discord.py support slash commands?

discord.py does not support slash commands and will never add support for slash commands (as it has shut down) thus I recommend disnake (a popular fork).


1 Answers

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)))
like image 75
mental Avatar answered Sep 17 '22 15:09

mental