Skip to content

Commit

Permalink
Add ping command
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Jan 3, 2024
1 parent fe838ba commit 7489f35
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions bot/cogs/utilities.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import datetime
import itertools
import platform
from time import perf_counter

import discord
import psutil
import pygit2
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


Expand Down Expand Up @@ -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"""
Expand Down

0 comments on commit 7489f35

Please sign in to comment.