[commands] Remove HelpCommand.clean_prefix (#6736)
This commit is contained in:
parent
90d59bb06c
commit
ffea48f218
@ -375,18 +375,6 @@ class HelpCommand:
|
|||||||
mapping[None] = [c for c in bot.commands if c.cog is None]
|
mapping[None] = [c for c in bot.commands if c.cog is None]
|
||||||
return mapping
|
return mapping
|
||||||
|
|
||||||
@property
|
|
||||||
def clean_prefix(self):
|
|
||||||
""":class:`str`: The cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``."""
|
|
||||||
user = self.context.guild.me if self.context.guild else self.context.bot.user
|
|
||||||
# this breaks if the prefix mention is not the bot itself but I
|
|
||||||
# consider this to be an *incredibly* strange use case. I'd rather go
|
|
||||||
# for this common use case rather than waste performance for the
|
|
||||||
# odd one.
|
|
||||||
pattern = re.compile(fr"<@!?{user.id}>")
|
|
||||||
display_name = user.display_name.replace('\\', r'\\')
|
|
||||||
return pattern.sub('@' + display_name, self.context.prefix)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def invoked_with(self):
|
def invoked_with(self):
|
||||||
"""Similar to :attr:`Context.invoked_with` except properly handles
|
"""Similar to :attr:`Context.invoked_with` except properly handles
|
||||||
@ -441,7 +429,7 @@ class HelpCommand:
|
|||||||
else:
|
else:
|
||||||
alias = command.name if not parent_sig else parent_sig + ' ' + command.name
|
alias = command.name if not parent_sig else parent_sig + ' ' + command.name
|
||||||
|
|
||||||
return f'{self.clean_prefix}{alias} {command.signature}'
|
return f'{self.context.clean_prefix}{alias} {command.signature}'
|
||||||
|
|
||||||
def remove_mentions(self, string):
|
def remove_mentions(self, string):
|
||||||
"""Removes mentions from the string to prevent abuse.
|
"""Removes mentions from the string to prevent abuse.
|
||||||
@ -938,8 +926,8 @@ class DefaultHelpCommand(HelpCommand):
|
|||||||
""":class:`str`: Returns help command's ending note. This is mainly useful to override for i18n purposes."""
|
""":class:`str`: Returns help command's ending note. This is mainly useful to override for i18n purposes."""
|
||||||
command_name = self.invoked_with
|
command_name = self.invoked_with
|
||||||
return (
|
return (
|
||||||
f"Type {self.clean_prefix}{command_name} command for more info on a command.\n"
|
f"Type {self.context.clean_prefix}{command_name} command for more info on a command.\n"
|
||||||
f"You can also type {self.clean_prefix}{command_name} category for more info on a category."
|
f"You can also type {self.context.clean_prefix}{command_name} category for more info on a category."
|
||||||
)
|
)
|
||||||
|
|
||||||
def add_indented_commands(self, commands, *, heading, max_size=None):
|
def add_indented_commands(self, commands, *, heading, max_size=None):
|
||||||
@ -1151,12 +1139,12 @@ class MinimalHelpCommand(HelpCommand):
|
|||||||
"""
|
"""
|
||||||
command_name = self.invoked_with
|
command_name = self.invoked_with
|
||||||
return (
|
return (
|
||||||
f"Use `{self.clean_prefix}{command_name} [command]` for more info on a command.\n"
|
f"Use `{self.context.clean_prefix}{command_name} [command]` for more info on a command.\n"
|
||||||
f"You can also use `{self.clean_prefix}{command_name} [category]` for more info on a category."
|
f"You can also use `{self.context.clean_prefix}{command_name} [category]` for more info on a category."
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_command_signature(self, command):
|
def get_command_signature(self, command):
|
||||||
return f'{self.clean_prefix}{command.qualified_name} {command.signature}'
|
return f'{self.context.clean_prefix}{command.qualified_name} {command.signature}'
|
||||||
|
|
||||||
def get_ending_note(self):
|
def get_ending_note(self):
|
||||||
"""Return the help command's ending note. This is mainly useful to override for i18n purposes.
|
"""Return the help command's ending note. This is mainly useful to override for i18n purposes.
|
||||||
@ -1205,7 +1193,7 @@ class MinimalHelpCommand(HelpCommand):
|
|||||||
The command to show information of.
|
The command to show information of.
|
||||||
"""
|
"""
|
||||||
fmt = '{0}{1} \N{EN DASH} {2}' if command.short_doc else '{0}{1}'
|
fmt = '{0}{1} \N{EN DASH} {2}' if command.short_doc else '{0}{1}'
|
||||||
self.paginator.add_line(fmt.format(self.clean_prefix, command.qualified_name, command.short_doc))
|
self.paginator.add_line(fmt.format(self.context.clean_prefix, command.qualified_name, command.short_doc))
|
||||||
|
|
||||||
def add_aliases_formatting(self, aliases):
|
def add_aliases_formatting(self, aliases):
|
||||||
"""Adds the formatting information on a command's aliases.
|
"""Adds the formatting information on a command's aliases.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user