Skip to content

Commit

Permalink
Remove opt-in feature :(
Browse files Browse the repository at this point in the history
  • Loading branch information
Flonja committed Oct 10, 2023
1 parent 660a63a commit 96c0b27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
12 changes: 0 additions & 12 deletions server/cmd/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ type Command struct {
description string
usage string
aliases []string
visible bool
}

// New returns a new Command using the name and description passed. The Runnable passed must be a
Expand Down Expand Up @@ -92,12 +91,6 @@ func New(name, description string, aliases []string, r ...Runnable) Command {
return Command{name: name, description: description, aliases: aliases, v: runnableValues, usage: strings.Join(usages, "\n")}
}

// WithAlwaysVisible sets the visible field of the Command struct to the passed value.
func (cmd Command) WithAlwaysVisible(alwaysVisible bool) Command {
cmd.visible = alwaysVisible
return cmd
}

// Name returns the name of the command. The name is guaranteed to be lowercase and will never have spaces in
// it. This name is used to call the command, and is shown in the /help list.
func (cmd Command) Name() string {
Expand All @@ -122,11 +115,6 @@ func (cmd Command) Aliases() []string {
return cmd.aliases
}

// AlwaysVisible specifies if a command should still be visible even if Allower returned false
func (cmd Command) AlwaysVisible() bool {
return cmd.visible
}

// Execute executes the Command as a source with the args passed. The args are parsed assuming they do not
// start with the command name. Execute will attempt to parse and execute one Runnable at a time. If one of
// the Runnable was able to parse args correctly, it will be executed and no more Runnables will be attempted
Expand Down
4 changes: 2 additions & 2 deletions server/session/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (s *Session) sendAvailableCommands() map[string]map[int]cmd.Runnable {
// Don't add duplicate entries for aliases.
continue
}
if run := c.Runnables(s.c); len(run) > 0 || c.AlwaysVisible() {
if run := c.Runnables(s.c); len(run) > 0 {
m[alias] = run
} else {
continue
Expand Down Expand Up @@ -203,7 +203,7 @@ func (s *Session) resendCommands(before map[string]map[int]cmd.Runnable) (map[st

for alias, c := range commands {
if c.Name() == alias {
if run := c.Runnables(s.c); len(run) > 0 || c.AlwaysVisible() {
if run := c.Runnables(s.c); len(run) > 0 {
m[alias] = run
}
}
Expand Down

0 comments on commit 96c0b27

Please sign in to comment.