MessageHelp
type alias in meocord/interface Since 4.1.0
type MessageHelp =
| { kind: 'list'; commands: MessageHelpEntry[]; invocation: string }
| { kind: 'command'; commands: MessageHelpEntry[]; invocation: string }
| { kind: 'parent'; subcommands: MessageHelpEntry[]; invocation: string }
| { kind: 'unknown'; query: string; invocation: string }
| { kind: 'empty'; reason: 'none' | 'server-only'; invocation: string }What the built-in help command found, for a presenter's messageHelp to write.
list is every command that works here, but for hidden ones and those with guards; command is the one a
!help <command> names; parent is the subcommands of the words it names; unknown is a name no command has;
empty is nothing to list.
Examples
@Service()
export class HelpPresenter implements ResponsePresenter {
loading = ({ theme }: ResponseContext) => ({ text: 'Working on it…', emoji: theme.emojis.loading })
error = (_context: ResponseContext, { message }: PresentedError) => ({ text: message })
messageHelp(help: MessageHelp) {
if (help.kind !== 'list') return help.kind === 'unknown' ? `No "${help.query}" here.` : 'Ask a moderator.'
return help.commands.map(entry => `${entry.usage}: ${entry.description ?? ''}`).join('\n')
}
}