Add help sections for all commands

This commit is contained in:
Tulir Asokan 2023-03-01 20:41:10 +02:00
parent 2440ca4e83
commit 0403a705b6
2 changed files with 11 additions and 7 deletions

View file

@ -47,6 +47,8 @@ type WrappedCommandEvent struct {
Portal *Portal Portal *Portal
} }
var HelpSectionPortalManagement = commands.HelpSection{Name: "Portal management", Order: 20}
func (br *DiscordBridge) RegisterCommands() { func (br *DiscordBridge) RegisterCommands() {
proc := br.CommandProcessor.(*commands.Processor) proc := br.CommandProcessor.(*commands.Processor)
proc.AddHandlers( proc.AddHandlers(
@ -327,7 +329,7 @@ var cmdRejoinSpace = &commands.FullHandler{
Func: wrapCommand(fnRejoinSpace), Func: wrapCommand(fnRejoinSpace),
Name: "rejoin-space", Name: "rejoin-space",
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionPortalManagement,
Description: "Ask the bridge for an invite to a space you left", Description: "Ask the bridge for an invite to a space you left",
Args: "<_guild ID_/main/dms>", Args: "<_guild ID_/main/dms>",
}, },
@ -360,7 +362,7 @@ var cmdSetRelay = &commands.FullHandler{
Func: wrapCommand(fnSetRelay), Func: wrapCommand(fnSetRelay),
Name: "set-relay", Name: "set-relay",
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionPortalManagement,
Description: "Create or set a relay webhook for a portal", Description: "Create or set a relay webhook for a portal",
Args: "[room ID] <--url URL> OR <--create [name]>", Args: "[room ID] <--url URL> OR <--create [name]>",
}, },
@ -470,7 +472,7 @@ var cmdUnsetRelay = &commands.FullHandler{
Func: wrapCommand(fnUnsetRelay), Func: wrapCommand(fnUnsetRelay),
Name: "unset-relay", Name: "unset-relay",
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionPortalManagement,
Description: "Disable the relay webhook and optionally delete it on Discord", Description: "Disable the relay webhook and optionally delete it on Discord",
Args: "[--delete]", Args: "[--delete]",
}, },
@ -504,7 +506,7 @@ var cmdGuilds = &commands.FullHandler{
Name: "guilds", Name: "guilds",
Aliases: []string{"servers", "guild", "server"}, Aliases: []string{"servers", "guild", "server"},
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionPortalManagement,
Description: "Guild bridging management", Description: "Guild bridging management",
Args: "<status/bridge/unbridge/bridging-mode> [_guild ID_] [...]", Args: "<status/bridge/unbridge/bridging-mode> [_guild ID_] [...]",
}, },
@ -618,7 +620,7 @@ var cmdDeleteAllPortals = &commands.FullHandler{
Func: wrapCommand(fnDeleteAllPortals), Func: wrapCommand(fnDeleteAllPortals),
Name: "delete-all-portals", Name: "delete-all-portals",
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: commands.HelpSectionAdmin,
Description: "Delete all portals.", Description: "Delete all portals.",
}, },
RequiresAdmin: true, RequiresAdmin: true,

View file

@ -28,12 +28,14 @@ import (
"maunium.net/go/mautrix/bridge/commands" "maunium.net/go/mautrix/bridge/commands"
) )
var HelpSectionDiscordBots = commands.HelpSection{Name: "Discord bot interaction", Order: 30}
var cmdCommands = &commands.FullHandler{ var cmdCommands = &commands.FullHandler{
Func: wrapCommand(fnCommands), Func: wrapCommand(fnCommands),
Name: "commands", Name: "commands",
Aliases: []string{"cmds", "cs"}, Aliases: []string{"cmds", "cs"},
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionDiscordBots,
Description: "View parameters of bot interaction commands on Discord", Description: "View parameters of bot interaction commands on Discord",
Args: "search <_query_> OR help <_command_>", Args: "search <_query_> OR help <_command_>",
}, },
@ -46,7 +48,7 @@ var cmdExec = &commands.FullHandler{
Name: "exec", Name: "exec",
Aliases: []string{"command", "cmd", "c", "exec", "e"}, Aliases: []string{"command", "cmd", "c", "exec", "e"},
Help: commands.HelpMeta{ Help: commands.HelpMeta{
Section: commands.HelpSectionUnclassified, Section: HelpSectionDiscordBots,
Description: "Run bot interaction commands on Discord", Description: "Run bot interaction commands on Discord",
Args: "<_command_> [_arg=value ..._]", Args: "<_command_> [_arg=value ..._]",
}, },