mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-09-28 21:29:25 +00:00
Bot: Added FindCommand
This commit is contained in:
parent
fb1b028ad7
commit
922c32c0eb
|
@ -153,6 +153,18 @@ func (sub *Subcommand) NeedsName() {
|
||||||
sub.Flag = flag
|
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.
|
// ChangeCommandInfo changes the matched methodName's Command and Description.
|
||||||
// Empty means unchanged. The returned bool is true when the method is found.
|
// Empty means unchanged. The returned bool is true when the method is found.
|
||||||
func (sub *Subcommand) ChangeCommandInfo(methodName, cmd, desc string) bool {
|
func (sub *Subcommand) ChangeCommandInfo(methodName, cmd, desc string) bool {
|
||||||
|
|
Loading…
Reference in a new issue