From 0bd0be38d3456aa2d39fd6c40ce92580ae62dffa Mon Sep 17 00:00:00 2001 From: No767 <73260931+No767@users.noreply.github.com> Date: Tue, 2 Jan 2024 18:30:44 -0800 Subject: [PATCH] Fix `?about` command not working on Docker --- bot/cogs/utilities.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bot/cogs/utilities.py b/bot/cogs/utilities.py index fbfa0b9..997bb9e 100644 --- a/bot/cogs/utilities.py +++ b/bot/cogs/utilities.py @@ -8,6 +8,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 @@ -51,6 +52,12 @@ def get_last_commits(self, count: int = 5): ) return "\n".join(self.format_commit(c) for c in commits) + def get_current_branch( + self, + ) -> str: + repo = pygit2.Repository(".git") + return repo.head.shorthand + async def fetch_num_active_tickets(self) -> int: query = "SELECT COUNT(*) FROM tickets;" value = await self.bot.pool.fetchval(query) @@ -77,12 +84,13 @@ async def about(self, ctx: RoboContext) -> None: memory_usage = self.process.memory_full_info().uss / 1024**2 cpu_usage = self.process.cpu_percent() / psutil.cpu_count() - revisions = self.get_last_commits() - revision_text = f"\n\nLatest Changes:\n {revisions}" - if is_docker(): - revision_text = ( - "\n\nSee [GitHub](https://github.com/transprogrammer/rodhaj)" - ) + revisions = "See [GitHub](https://github.com/transprogrammer/rodhaj)" + working_branch = "Docker" + + if not is_docker(): + revisions = self.get_last_commits() + working_branch = self.get_current_branch() + footer_text = ( "Developed by Noelle and the Transprogrammer dev team\n" f"Made with discord.py v{discord.__version__} | Running Python {platform.python_version()}" @@ -95,7 +103,7 @@ async def about(self, ctx: RoboContext) -> None: "the transprogrammer community. By creating a shared inbox, " "it allows for users and staff to seamlessly communicate safely, securely, and privately. " "In order to start using Rodhaj, please DM Rodhaj to make a ticket. " - f"{revision_text}" + f"\n\nLatest Changes ({working_branch}):\n {revisions}" ) embed.set_footer( text=footer_text,