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)
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.
According to the maintainer, Discord has told that the bots will continue to work fine even after April 2022.
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).
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)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With