from discord import ApplicationContext, Cog, slash_command from libbot.i18n import _, in_every_locale from classes.pycord_bot import PycordBot from modules.utils import get_current_commit, get_unix_timestamp class CogStatus(Cog): """Cog with the status command.""" def __init__(self, bot: PycordBot): self.bot: PycordBot = bot @slash_command( name="status", description=_("description", "commands", "status"), description_localizations=in_every_locale("description", "commands", "status"), ) async def command_status(self, ctx: ApplicationContext) -> None: current_commit: str | None = await get_current_commit() if current_commit is None: await ctx.respond( self.bot._("status", "messages", locale=ctx.locale).format( version=self.bot.__version__, start_time=get_unix_timestamp(self.bot.started), ) ) return await ctx.respond( self.bot._("status_git", "messages", locale=ctx.locale).format( version=self.bot.__version__, commit=current_commit if len(current_commit) < 10 else current_commit[:10], start_time=get_unix_timestamp(self.bot.started), ) ) def setup(bot: PycordBot) -> None: bot.add_cog(CogStatus(bot))