feat(pterodactyl): added custom formatting for the cog-level help embed
All checks were successful
Actions / Build Documentation (MkDocs) (push) Successful in 36s
Actions / Lint Code (Ruff & Pylint) (push) Successful in 44s

This commit is contained in:
Seaswimmer 2024-03-29 07:18:55 -04:00
parent 3066848853
commit ba25078f3f
Signed by: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -9,7 +9,7 @@ from pydactyl import PterodactylClient
from redbot.core import app_commands, commands
from redbot.core.app_commands import Choice
from redbot.core.bot import Red
from redbot.core.utils.chat_formatting import box, error
from redbot.core.utils.chat_formatting import box, error, humanize_list
from redbot.core.utils.views import ConfirmView
from pterodactyl import mcsrvstatus
@ -20,6 +20,10 @@ from pterodactyl.logger import logger
class Pterodactyl(commands.Cog):
"""Pterodactyl allows you to manage your Pterodactyl Panel from Discord."""
__author__ = ["SeaswimmerTheFsh"]
__version__ = "2.0.0"
__documentation__ = "https://seacogs.coastalcommits.com/pterodactyl/"
def __init__(self, bot: Red):
self.bot = bot
self.client: Optional[PterodactylClient] = None
@ -30,6 +34,17 @@ class Pterodactyl(commands.Cog):
self.task = self.get_task()
self.update_topic.start()
def format_help_for_context(self, ctx: commands.Context) -> str:
pre_processed = super().format_help_for_context(ctx) or ""
n = "\n" if "\n\n" not in pre_processed else ""
text = [
f"{pre_processed}{n}",
f"Cog Version: **{self.__version__}**",
f"Author: {humanize_list(self.__author__)}",
f"Documentation: {self.__documentation__}",
]
return "\n".join(text)
async def cog_unload(self) -> None:
self.update_topic.cancel()
self.task.cancel()