Skip to content

Commit

Permalink
ping: rework (still needs style rework)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaeeraa committed Oct 23, 2024
1 parent a40105c commit 5433609
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions commands/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,36 @@
/ping
"""

from datetime import datetime
from json import load
from urllib.request import urlopen

from arc import GatewayContext, slash_command
from hikari import Color, Embed
from hikari import Color
from hikari.embeds import Embed

from instances.bot import bot
from instances.log import logger

logger.trace("Initialising ping command")

data = load(urlopen("http://ipinfo.io/json"))


@slash_command(name="ping", description="Returns the bot's heartbeat latency.")
async def ping(ctx: GatewayContext) -> None:
logger.trace(f"/ping command called ({ctx.author.username})")
embed: Embed = Embed(
title="🏓 Pong!",
description=f"📶 Latency: {round(bot.heartbeat_latency * 1000)}ms",
color=Color.from_rgb(200, 90, 70),
# we cant use # in title, so not using it
# title="🏓 Pong!",
description=(
f"## 🌍 Server Geo: {data['country']}, {data['region']}\n"
f"### ⏳ Latency: {round(bot.heartbeat_latency * 1000)}ms"
),
color=Color.from_rgb(90, 0, 240),
)
embed.set_footer(
text=f"Matter • Called by @{ctx.author.username}{datetime.now().strftime('%H:%M:%S')}",
icon=ctx.author.avatar_url,
)
await ctx.respond(embed=embed)

0 comments on commit 5433609

Please sign in to comment.