how to make a latency command discord py

Solutions on MaxInterview for how to make a latency command discord py by the best coders in the world

showing results for - "how to make a latency command discord py"
Jebediah
25 Sep 2017
1@client.command()
2async def ping(ctx):
3    before = time.monotonic()
4    message = await ctx.send("Pong!")
5    ping = (time.monotonic() - before) * 1000
6    await message.edit(content=f"Pong!  `{int(ping)}ms`")
7    
8    #for discord.py rewrite
Sofia
19 Aug 2019
1@bot.command(name="ping", pass_context=True, aliases=["latency", "latence"])
2async def ping(ctx):
3    
4    embed = discord.Embed(title="__**Latence**__", colour=discord.Color.dark_gold(), timestamp=ctx.message.created_at)
5    embed.add_field(name="Latence du bot :", value=f"`{round(bot.latency * 1000)} ms`")
6
7    await ctx.send(embed=embed)
8    
9    """
10    Text in french
11    """