1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 17:23:00 +00:00

Bot: Added FindCommand

This commit is contained in:
diamondburned (Forefront) 2020-04-08 23:06:46 -07:00
parent fb1b028ad7
commit 922c32c0eb

View file

@ -153,6 +153,18 @@ func (sub *Subcommand) NeedsName() {
sub.Flag = flag
}
// FindCommand finds the command. Nil is returned if nothing is found. It's a
// better idea to not handle nil, as they would become very subtle bugs.
func (sub *Subcommand) FindCommand(methodName string) *CommandContext {
for _, c := range sub.Commands {
if c.MethodName != methodName {
continue
}
return c
}
return nil
}
// ChangeCommandInfo changes the matched methodName's Command and Description.
// Empty means unchanged. The returned bool is true when the method is found.
func (sub *Subcommand) ChangeCommandInfo(methodName, cmd, desc string) bool {