This commit is contained in:
r4
2021-07-28 17:30:01 +02:00
parent 6dfb9bc0b1
commit d2fae31d1a
12 changed files with 1501 additions and 0 deletions

16
args.go Normal file
View File

@@ -0,0 +1,16 @@
// Parses the commands sent through Discord. This program does not use any
// traditional command line options, as it uses config.json for configuration.
package main
import (
"strings"
)
// Returns a false and a nil slice if cmd was not intended for the bot.
func CmdGetArgs(cmd string) (args []string, ok bool) {
if !strings.HasPrefix(cmd, cfg.Prefix) {
return nil, false
}
cmd = strings.TrimPrefix(cmd, cfg.Prefix)
return strings.Fields(cmd), true
}