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 version display and bump micro #442

Merged
merged 1 commit into from
Jul 1, 2023
Merged
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
27 changes: 26 additions & 1 deletion adventure/adventure.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def red_delete_data_for_user(
user_id
).clear() # This will only ever touch the separate currency, leaving bot economy to be handled by core.

__version__ = "4.0.1"
__version__ = "4.0.2"

def __init__(self, bot: Red):
self.bot = bot
Expand Down Expand Up @@ -188,6 +188,24 @@ def __init__(self, bot: Red):
self.app_command.remove_command("adventure")
self._adventure.app_command.name = "start"
self.app_command.add_command(self._adventure.app_command)
self._commit = ""
self._repo = ""

def format_help_for_context(self, ctx: commands.Context) -> str:
"""
Thanks Sinbad!

How many people are going to copy this one?
"""
pre_processed = super().format_help_for_context(ctx)
ret = f"{pre_processed}\n\nCog Version: {self.__version__}\n"
# we'll only have a repo if the cog was installed through Downloader at some point
if self._repo:
ret += f"Repo: {self._repo}\n"
# we should have a commit if we have the repo but just incase
if self._commit:
ret += f"Commit: [{self._commit[:9]}]({self._repo}/tree/{self._commit})"
return ret

async def cog_before_invoke(self, ctx: commands.Context):
await self._ready_event.wait()
Expand All @@ -203,6 +221,13 @@ async def _clear_react(self, msg: discord.Message):
async def initialize(self):
"""This will load all the bundled data into respective variables."""
await self.bot.wait_until_red_ready()
downloader = self.bot.get_cog("Downloader")
if downloader is not None:
cogs = await downloader.installed_cogs()
for cog in cogs:
if cog.name == "adventure":
self._repo = cog.repo.clean_url
self._commit = cog.repo.commit
try:
global _config
_config = self.config
Expand Down
Loading