HasCommand returns true if the command name is in the command list.
(name string)
| 209 | |
| 210 | // HasCommand returns true if the command name is in the command list. |
| 211 | func (c commandList) HasCommand(name string) bool { |
| 212 | if name == "" { |
| 213 | return false |
| 214 | } |
| 215 | |
| 216 | cType := reflect.TypeOf(c) |
| 217 | _, found := cType.FieldByNameFunc( |
| 218 | func(fieldName string) bool { |
| 219 | field, _ := cType.FieldByName(fieldName) |
| 220 | return field.Tag.Get("command") == name |
| 221 | }, |
| 222 | ) |
| 223 | |
| 224 | return found |
| 225 | } |
| 226 | |
| 227 | // HasAlias returns true if the command alias is in the command list. |
| 228 | func (c commandList) HasAlias(alias string) bool { |