Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of ping and uptime commands #1542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions bot/exts/core/ping.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import arrow

Check failure on line 1 in bot/exts/core/ping.py

View workflow job for this annotation

GitHub Actions / lint / Run linting & tests

Ruff (F401)

bot/exts/core/ping.py:1:8: F401 `arrow` imported but unused
from dateutil.relativedelta import relativedelta

Check failure on line 2 in bot/exts/core/ping.py

View workflow job for this annotation

GitHub Actions / lint / Run linting & tests

Ruff (F401)

bot/exts/core/ping.py:2:36: F401 `dateutil.relativedelta.relativedelta` imported but unused
from discord import Embed
from discord.ext import commands
from discord.utils import format_dt

from bot import start_time
from bot.bot import Bot
Expand All @@ -20,7 +21,7 @@
embed = Embed(
title=":ping_pong: Pong!",
colour=Colours.bright_green,
description=f"Gateway Latency: {round(self.bot.latency * 1000)}ms",
description=f"Gateway Latency: `{round(self.bot.latency * 1000)}`ms",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

I think both ways look fine, so I don't really think it's worth changing unless there's a good reason.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I guess it's personal preference but definitely not a necessary change.

)

await ctx.send(embed=embed)
Expand All @@ -29,17 +30,8 @@
@commands.command(name="uptime")
async def uptime(self, ctx: commands.Context) -> None:
"""Get the current uptime of the bot."""
difference = relativedelta(start_time - arrow.utcnow())
uptime_string = start_time.shift(
seconds=-difference.seconds,
minutes=-difference.minutes,
hours=-difference.hours,
days=-difference.days
).humanize()

await ctx.send(f"I started up {uptime_string}.")

await ctx.reply(f"I started up {format_dt(start_time.datetime, 'R')}.")

async def setup(bot: Bot) -> None:

Check failure on line 35 in bot/exts/core/ping.py

View workflow job for this annotation

GitHub Actions / lint / Run linting & tests

Ruff (E302)

bot/exts/core/ping.py:35:1: E302 Expected 2 blank lines, found 1
"""Load the Ping cog."""
await bot.add_cog(Ping(bot))
Loading