diff options
| author | 2018-11-14 23:45:29 +0000 | |
|---|---|---|
| committer | 2018-11-14 23:45:29 +0000 | |
| commit | f486d2209eba9a4cbd68684771382ec9dc1c9005 (patch) | |
| tree | 815391878d6d1bc40e7619c0fdad6dc0277b039e | |
| parent | Merge branch 'issue/73-delete-eval-results' into 'master' (diff) | |
| parent | #75: Add a help menu for aliases. (diff) | |
Merge branch 'issue/75-help-menu-for-aliases' into 'master'
#75: Add a help menu for aliases.
See merge request python-discord/projects/bot!84
| -rw-r--r-- | bot/cogs/alias.py | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/bot/cogs/alias.py b/bot/cogs/alias.py index 7b342a2d0..ea36b5ebd 100644 --- a/bot/cogs/alias.py +++ b/bot/cogs/alias.py @@ -1,11 +1,13 @@ +import inspect import logging -from discord import TextChannel, User +from discord import Colour, Embed, TextChannel, User from discord.ext.commands import ( - Context, clean_content, command, group + Command, Context, clean_content, command, group ) from bot.converters import TagNameConverter +from bot.pagination import LinePaginator log = logging.getLogger(__name__) @@ -41,6 +43,24 @@ class Alias: await ctx.invoke(cmd, *args, **kwargs) + @command(name='aliases') + async def aliases_command(self, ctx): + """Show configured aliases on the bot.""" + + embed = Embed( + title='Configured aliases', + colour=Colour.blue() + ) + await LinePaginator.paginate( + ( + f"• `{ctx.prefix}{value.name}` " + f"=> `{ctx.prefix}{name[:-len('_alias')].replace('_', ' ')}`" + for name, value in inspect.getmembers(self) + if isinstance(value, Command) and name.endswith('_alias') + ), + ctx, embed, empty=False, max_lines=20 + ) + @command(name="resources", aliases=("resource",), hidden=True) async def site_resources_alias(self, ctx): """ @@ -94,7 +114,7 @@ class Alias: await self.invoke(ctx, "site rules") @command(name="reload", hidden=True) - async def reload_cog_alias(self, ctx, *, cog_name: str): + async def cogs_reload_alias(self, ctx, *, cog_name: str): """ Alias for invoking <prefix>cogs reload cog_name. @@ -132,7 +152,7 @@ class Alias: pass @get_group_alias.command(name="tags", aliases=("tag", "t"), hidden=True) - async def get_tags_command_alias( + async def tags_get_alias( self, ctx: Context, *, tag_name: TagNameConverter=None ): """ @@ -144,7 +164,7 @@ class Alias: await self.invoke(ctx, "tags get", tag_name) @get_group_alias.command(name="docs", aliases=("doc", "d"), hidden=True) - async def get_docs_command_alias( + async def docs_get_alias( self, ctx: Context, symbol: clean_content = None ): """ |