1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-01-07 12:38:05 +00:00

Added HelpAdmin

This commit is contained in:
diamondburned (Forefront) 2020-01-23 22:20:02 -08:00
parent 79567a9eff
commit 95f06cca45

View file

@ -273,6 +273,14 @@ func (ctx *Context) Call(event interface{}) error {
// Help generates one. This function is used more for reference than an actual // Help generates one. This function is used more for reference than an actual
// help message. As such, it only uses exported fields or methods. // help message. As such, it only uses exported fields or methods.
func (ctx *Context) Help() string { func (ctx *Context) Help() string {
return ctx.help(true)
}
func (ctx *Context) HelpAdmin() string {
return ctx.help(false)
}
func (ctx *Context) help(hideAdmin bool) string {
var help strings.Builder var help strings.Builder
// Generate the headers and descriptions // Generate the headers and descriptions
@ -298,8 +306,7 @@ func (ctx *Context) Help() string {
help.WriteString("__Commands__\n") help.WriteString("__Commands__\n")
for _, cmd := range ctx.Commands { for _, cmd := range ctx.Commands {
if cmd.Flag.Is(AdminOnly) { if cmd.Flag.Is(AdminOnly) && hideAdmin {
// Hidden
continue continue
} }
@ -319,8 +326,7 @@ func (ctx *Context) Help() string {
var subcommands = ctx.Subcommands() var subcommands = ctx.Subcommands()
for _, sub := range subcommands { for _, sub := range subcommands {
if sub.Flag.Is(AdminOnly) { if sub.Flag.Is(AdminOnly) && hideAdmin {
// Hidden
continue continue
} }
@ -333,7 +339,7 @@ func (ctx *Context) Help() string {
subHelp.WriteByte('\n') subHelp.WriteByte('\n')
for _, cmd := range sub.Commands { for _, cmd := range sub.Commands {
if cmd.Flag.Is(AdminOnly) { if cmd.Flag.Is(AdminOnly) && hideAdmin {
continue continue
} }