Merge pull request #354 from miaowware/helppfx

Prefixes and the ?help command
This commit is contained in:
0x5c 2021-03-13 18:31:29 -05:00 committed by GitHub
commit 0d5ca5c2fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Commands to show METAR (`?metar`) and TAF (`?taf`) (aeronautical weather conditions).
- The ability to select an element of a pool in `?hamstudy`.
- The ability to answer ❓ to a HamStudy question to get the answer.
- The list of available prefixes to `?help` when there is more than one.
### Changed
- New colour theme for `?greyline`.
- Moved great circle distance and bearing calculation from `?ungrid` to `?griddistance`.
@ -18,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Reduced `?hamstudy` timeout to 5 minutes.
### Fixed
- Weird image caching situation for `?greyline` on Discord's side.
- The help command was not using the prefix it was invoked with.
### Deprecated
- `?ungrid`.
- Deprecated old `?solar` aliases (`?cond`, etc).

View File

@ -19,13 +19,12 @@ import discord.ext.commands as commands
import info
import common as cmn
import data.options as opt
class QrmHelpCommand(commands.HelpCommand):
def __init__(self):
super().__init__(command_attrs={"help": "Shows help about qrm or a command", "aliases": ["h"]})
self.verify_checks = True
self.context: commands.Context
async def get_bot_mapping(self):
bot = self.context.bot
@ -47,9 +46,9 @@ class QrmHelpCommand(commands.HelpCommand):
if parent:
fmt = f"{parent} {fmt}"
alias = fmt
return f"{opt.display_prefix}{alias} {command.signature}\n *Aliases:* {aliases}"
return f"{self.context.prefix}{alias} {command.signature}\n *Aliases:* {aliases}"
alias = command.name if not parent else f"{parent} {command.name}"
return f"{opt.display_prefix}{alias} {command.signature}"
return f"{self.context.prefix}{alias} {command.signature}"
async def send_error_message(self, error):
embed = cmn.embed_factory(self.context)
@ -61,8 +60,11 @@ class QrmHelpCommand(commands.HelpCommand):
async def send_bot_help(self, mapping):
embed = cmn.embed_factory(self.context)
embed.title = "qrm Help"
embed.description = (f"For command-specific help and usage, use `{opt.display_prefix}help [command name]`."
embed.description = (f"For command-specific help and usage, use `{self.context.prefix}help [command name]`."
" Many commands have shorter aliases.")
if isinstance(self.context.bot.command_prefix, list):
embed.description += (" All of the following prefixes work with the bot: `"
+ "`, `".join(self.context.bot.command_prefix) + "`.")
mapping = await mapping
for cat, cmds in mapping.items():