From 7a05632bf04cab74da8c13baab5570729c7a5420 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh <102361830+SeaswimmerTheFsh@users.noreply.github.com> Date: Mon, 19 Jun 2023 19:01:43 -0400 Subject: [PATCH] updated ping command --- main.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 2e23a26..0c0739e 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ from dotenv import load_dotenv import aiohttp import revolt from revolt.ext import commands +import time load_dotenv() token = os.getenv('TOKEN') @@ -17,8 +18,15 @@ class Client(commands.CommandsClient): @commands.command() async def ping(self, ctx: commands.Context): - # This command checks if the bot is running. - await ctx.send("Pong!") + # This command checks the bot's latency. + before = time.monotonic() + await ctx.send("🏓") + mrm_list = await ctx.channel.history(limit=1) + mrm = mrm_list[0] + ping = (time.monotonic() - before) * 1000 + embeds = [revolt.SendableEmbed(title="🏓 Pong!", description=f"`\n{int(ping)} ms`", colour="#5d82d1")] + await mrm.edit(content=None, embeds=embeds) + print(f'Ping {int(ping)}ms') @commands.command() async def avatar(self, ctx: commands.Context, member: revolt.Member):