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

[Help] Allow prefix formatting in taglines #4972

Merged
merged 11 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions docs/cog_guides/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,11 @@ Set the tagline to be used.
The maximum tagline length is 2048 characters.
This setting only applies to embedded help. If no tagline is specified, the default will be used instead.

You can use ``[p]`` in your tagline, which will be replaced by the bot's prefix.

**Examples:**
- ``[p]helpset tagline Thanks for using the bot!``
- ``[p]helpset tagline Use [p]invite to add me to your server.``
- ``[p]helpset tagline`` - Resets the tagline to the default.

**Arguments:**
Expand Down
24 changes: 18 additions & 6 deletions redbot/core/commands/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,12 @@ def get_default_tagline(ctx: Context):
command2=f"{ctx.clean_prefix}help <category>",
)

@staticmethod
def format_tagline(ctx: Context, tagline: str):
if not tagline:
return
return tagline.replace("[p]", ctx.clean_prefix)

@staticmethod
def get_command_signature(ctx: Context, command: commands.Command) -> str:
parent = command.parent
Expand Down Expand Up @@ -345,7 +351,7 @@ async def format_command_help(

description = command.description or ""

tagline = (help_settings.tagline) or self.get_default_tagline(ctx)
tagline = self.format_tagline(ctx, help_settings.tagline) or self.get_default_tagline(ctx)
signature = _("Syntax: {command_signature}").format(
command_signature=self.get_command_signature(ctx, command)
)
Expand Down Expand Up @@ -569,7 +575,7 @@ async def format_cog_help(self, ctx: Context, obj: commands.Cog, help_settings:
return

description = obj.format_help_for_context(ctx)
tagline = (help_settings.tagline) or self.get_default_tagline(ctx)
tagline = self.format_tagline(ctx, help_settings.tagline) or self.get_default_tagline(ctx)

if await self.embed_requested(ctx):
emb = {"embed": {"title": "", "description": ""}, "footer": {"text": ""}, "fields": []}
Expand Down Expand Up @@ -642,7 +648,7 @@ async def format_bot_help(self, ctx: Context, help_settings: HelpSettings):
return

description = ctx.bot.description or ""
tagline = (help_settings.tagline) or self.get_default_tagline(ctx)
tagline = self.format_tagline(ctx, help_settings.tagline) or self.get_default_tagline(ctx)

if await self.embed_requested(ctx):
emb = {"embed": {"title": "", "description": ""}, "footer": {"text": ""}, "fields": []}
Expand Down Expand Up @@ -763,7 +769,9 @@ async def command_not_found(self, ctx, help_for, help_settings: HelpSettings):
name=_("{ctx.me.display_name} Help Menu").format(ctx=ctx),
icon_url=ctx.me.display_avatar,
)
tagline = help_settings.tagline or self.get_default_tagline(ctx)
tagline = self.format_tagline(
ctx, help_settings.tagline
) or self.get_default_tagline(ctx)
ret.set_footer(text=tagline)
await ctx.send(embed=ret)
else:
Expand All @@ -776,7 +784,9 @@ async def command_not_found(self, ctx, help_for, help_settings: HelpSettings):
name=_("{ctx.me.display_name} Help Menu").format(ctx=ctx),
icon_url=ctx.me.display_avatar,
)
tagline = help_settings.tagline or self.get_default_tagline(ctx)
tagline = self.format_tagline(
ctx, help_settings.tagline
) or self.get_default_tagline(ctx)
ret.set_footer(text=tagline)
await ctx.send(embed=ret)
else:
Expand All @@ -795,7 +805,9 @@ async def subcommand_not_found(self, ctx, command, not_found, help_settings: Hel
name=_("{ctx.me.display_name} Help Menu").format(ctx=ctx),
icon_url=ctx.me.display_avatar,
)
tagline = help_settings.tagline or self.get_default_tagline(ctx)
tagline = self.format_tagline(ctx, help_settings.tagline) or self.get_default_tagline(
ctx
)
ret.set_footer(text=tagline)
await ctx.send(embed=ret)
else:
Expand Down
3 changes: 3 additions & 0 deletions redbot/core/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4535,8 +4535,11 @@ async def helpset_tagline(self, ctx: commands.Context, *, tagline: str = None):
The maximum tagline length is 2048 characters.
This setting only applies to embedded help. If no tagline is specified, the default will be used instead.

You can use `[\u200bp]` in your tagline, which will be replaced by the bot's prefix.

**Examples:**
- `[p]helpset tagline Thanks for using the bot!`
- `[p]helpset tagline Use [\u200bp]invite to add me to your server.`
- `[p]helpset tagline` - Resets the tagline to the default.

**Arguments:**
Expand Down
Loading