From d769063eed0beeb0d7fed64e1f9b4123cf3e1c9f Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Tue, 16 Apr 2024 23:25:58 +0530 Subject: [PATCH] Add `/ping` to measure server-API latency --- cogs/utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cogs/utils.py b/cogs/utils.py index 98a267e..30348c0 100644 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -41,6 +41,18 @@ async def echo(self, ctx: ApplicationContext, text: str): await ctx.respond("Echoed!", ephemeral=True) await ctx.channel.send(text) + @commands.slash_command( + name="ping", + description="Get the server latency." + ) + async def ping(self, ctx: ApplicationContext): + localembed = discord.Embed( + title=":ping_pong: Pong!", + description=f"Current server latency is **{round(self.bot.latency * 1000, 2)} ms**.", + color=discord.Color.random() + ) + await ctx.respond(embed=localembed) + @commands.slash_command( name="repo", description="Shows the open-source code links for isobot."