Refactor fuzzy help and clean up help command (#2122)

What's changed:
- Fixed issues mentioned on #2031
- Fuzzy help displays more like help manual
- Fuzzy help is easier and more flexible to use
- Fuzzy help string-matching ratio lowered to 80
- Help formatter is more extendable
- Help command has been optimized, cleaned up and better incorporates fuzzy help
- Added async_filter and async_enumerate utility functions because I was using them for this PR, then no longer needed them, but decided they might be useful anyway.
- Added `Context.me` property which is a shortcut to `Context.guild.me` or `Context.bot.user`, depending on the channel type.
This commit is contained in:
Toby Harradine
2018-09-24 10:34:39 +10:00
committed by GitHub
parent 32b4c6ce86
commit f7dbaca340
6 changed files with 398 additions and 218 deletions

View File

@@ -1,6 +1,6 @@
from copy import copy
from re import search
from typing import Generator, Tuple, Iterable
from typing import Generator, Tuple, Iterable, Optional
import discord
from redbot.core import Config, commands, checks
@@ -53,10 +53,13 @@ class Alias:
return (AliasEntry.from_json(d, bot=self.bot) for d in (await self._aliases.entries()))
async def is_alias(
self, guild: discord.Guild, alias_name: str, server_aliases: Iterable[AliasEntry] = ()
) -> (bool, AliasEntry):
self,
guild: Optional[discord.Guild],
alias_name: str,
server_aliases: Iterable[AliasEntry] = (),
) -> Tuple[bool, Optional[AliasEntry]]:
if not server_aliases:
if not server_aliases and guild is not None:
server_aliases = await self.unloaded_aliases(guild)
global_aliases = await self.unloaded_global_aliases()