From e9b59bb8e148210b42610c3348d1c1c30dc75acd Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Thu, 8 Apr 2021 23:01:25 +0100 Subject: [PATCH 01/10] [Help] Allow prefixes to be used in help tagline --- redbot/core/commands/help.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index f6a80b5f943..93703f991b0 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -55,6 +55,7 @@ EmbedField = namedtuple("EmbedField", "name value inline") EMPTY_STRING = "\N{ZERO WIDTH SPACE}" +tagline_prefix = lambda x, y: x.replace("[p]", y.clean_prefix) @dataclass(frozen=True) @@ -274,6 +275,10 @@ def get_default_tagline(ctx: Context): "Type {ctx.clean_prefix}help for more info on a command. " "You can also type {ctx.clean_prefix}help for more info on a category." ).format(ctx=ctx) + + @staticmethod + def format_tagline(ctx: Context, tagline: str): + return tagline.replace("[p]", ctx.clean_prefix) @staticmethod def get_command_signature(ctx: Context, command: commands.Command) -> str: @@ -313,7 +318,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) ) @@ -534,7 +539,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 ctx.embed_requested(): emb = {"embed": {"title": "", "description": ""}, "footer": {"text": ""}, "fields": []} @@ -601,7 +606,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 ctx.embed_requested(): @@ -722,7 +727,7 @@ 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.avatar_url, ) - 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: @@ -735,7 +740,7 @@ 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.avatar_url, ) - 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: @@ -754,7 +759,7 @@ 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.avatar_url, ) - 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: From 6915176883de0866a676073c1d9b2189c0672b52 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Thu, 8 Apr 2021 23:02:20 +0100 Subject: [PATCH 02/10] Remove the lambda which wasnt used --- redbot/core/commands/help.py | 1 - 1 file changed, 1 deletion(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index 93703f991b0..d96e4609b64 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -55,7 +55,6 @@ EmbedField = namedtuple("EmbedField", "name value inline") EMPTY_STRING = "\N{ZERO WIDTH SPACE}" -tagline_prefix = lambda x, y: x.replace("[p]", y.clean_prefix) @dataclass(frozen=True) From 799dafa0c8a0a2b73ea462256e8d545a201709a1 Mon Sep 17 00:00:00 2001 From: Kreusada Date: Thu, 8 Apr 2021 23:09:22 +0100 Subject: [PATCH 03/10] Fixes for black --- redbot/core/commands/help.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index d96e4609b64..2da46cbc29c 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -274,7 +274,7 @@ def get_default_tagline(ctx: Context): "Type {ctx.clean_prefix}help for more info on a command. " "You can also type {ctx.clean_prefix}help for more info on a category." ).format(ctx=ctx) - + @staticmethod def format_tagline(ctx: Context, tagline: str): return tagline.replace("[p]", ctx.clean_prefix) @@ -726,7 +726,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.avatar_url, ) - tagline = self.format_tagline(ctx, 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: @@ -739,7 +741,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.avatar_url, ) - tagline = self.format_tagline(ctx, 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: @@ -758,7 +762,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.avatar_url, ) - tagline = self.format_tagline(ctx, 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: From 5d5787c8cb12149265fe5b5bef2969133ac9bfa6 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Mon, 19 Apr 2021 20:54:56 +0100 Subject: [PATCH 04/10] update docstrings for clarity --- redbot/core/core_commands.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 68db79e5867..2f290003543 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3294,9 +3294,12 @@ 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:** From 2571829d01355067e4983fbab975a527c7df7d7b Mon Sep 17 00:00:00 2001 From: Kreusada Date: Mon, 19 Apr 2021 20:58:59 +0100 Subject: [PATCH 05/10] black --- redbot/core/core_commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 2f290003543..553f52a205f 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3294,7 +3294,7 @@ 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:** From b7c5112c04438118ddeddad0469080835bb56fbc Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Sun, 8 Aug 2021 11:52:12 +0100 Subject: [PATCH 06/10] update docs --- docs/cog_guides/core.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index fb7ee2d0e7a..a852cb4d3ca 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -1323,9 +1323,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`` - Resets the tagline to the default. + - `[p]helpset tagline Thanks for using the bot!` + - `[p]helpset tagline Use [p]invite to add me to your server.` **Arguments:** - ``[tagline]`` - The tagline to appear at the bottom of help embeds. Leave blank to reset. From 413f34ea3992060e50315434a7e93d3c552c5fbe Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Sun, 8 Aug 2021 11:54:37 +0100 Subject: [PATCH 07/10] fixes --- docs/cog_guides/core.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index a852cb4d3ca..3d6df757a90 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -1326,8 +1326,8 @@ This setting only applies to embedded help. If no tagline is specified, the defa 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 Thanks for using the bot!`` + - ``[p]helpset tagline Use [p]invite to add me to your server.`` **Arguments:** - ``[tagline]`` - The tagline to appear at the bottom of help embeds. Leave blank to reset. From e05783ee56289d49e4a9f0cb6bd4ac656cef6b02 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Sun, 8 Aug 2021 11:55:47 +0100 Subject: [PATCH 08/10] Update core.rst --- docs/cog_guides/core.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index 3d6df757a90..abbd40b0b72 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -1328,6 +1328,7 @@ 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:** - ``[tagline]`` - The tagline to appear at the bottom of help embeds. Leave blank to reset. From baf0bc4670f3f97a13632024feb5a33dc6f00041 Mon Sep 17 00:00:00 2001 From: Kreusada <67752638+Kreusada@users.noreply.github.com> Date: Sun, 8 Aug 2021 11:57:08 +0100 Subject: [PATCH 09/10] Update help.py --- redbot/core/commands/help.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/redbot/core/commands/help.py b/redbot/core/commands/help.py index 2da46cbc29c..0367d46ba67 100644 --- a/redbot/core/commands/help.py +++ b/redbot/core/commands/help.py @@ -277,6 +277,8 @@ def get_default_tagline(ctx: Context): @staticmethod def format_tagline(ctx: Context, tagline: str): + if not tagline: + return return tagline.replace("[p]", ctx.clean_prefix) @staticmethod From 4b490526d47801f5fa5552a73b86af82c24b84b7 Mon Sep 17 00:00:00 2001 From: Kreusada Date: Tue, 24 Aug 2021 20:12:38 +0100 Subject: [PATCH 10/10] Fix referencing issues --- docs/cog_guides/core.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index abbd40b0b72..df3ab6d7a50 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -1323,7 +1323,7 @@ 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. +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!``