From 7489f356a5790128c584360cab3203619beb8bd9 Mon Sep 17 00:00:00 2001 From: No767 <73260931+No767@users.noreply.github.com> Date: Tue, 2 Jan 2024 18:41:58 -0800 Subject: [PATCH] Add ping command --- bot/cogs/utilities.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/bot/cogs/utilities.py b/bot/cogs/utilities.py index 42ac3ee..fd44cc1 100644 --- a/bot/cogs/utilities.py +++ b/bot/cogs/utilities.py @@ -1,6 +1,7 @@ import datetime import itertools import platform +from time import perf_counter import discord import psutil @@ -8,6 +9,7 @@ from discord.ext import commands from discord.utils import format_dt from libs.utils import Embed, RoboContext, human_timedelta, is_docker + from rodhaj import Rodhaj @@ -122,6 +124,25 @@ async def about(self, ctx: RoboContext) -> None: embed.add_field(name="Uptime", value=self.get_bot_uptime(brief=True)) await ctx.send(embed=embed) + @commands.hybrid_command(name="ping") + async def ping(self, ctx: RoboContext) -> None: + """Obtains ping information""" + start = perf_counter() + await self.bot.pool.fetchrow("SELECT 1") + end = perf_counter() + db_ping = end - start + + embed = Embed() + embed.add_field( + name="DB Latency", value=f"```{db_ping * 1000:.2f}ms```", inline=False + ) + embed.add_field( + name="Websocket Latency", + value=f"```{self.bot.latency * 1000:.2f}ms```", + inline=False, + ) + await ctx.send(embed=embed) + @commands.hybrid_command(name="uptime") async def uptime(self, ctx: RoboContext) -> None: """Displays the bot's uptime"""