|
|
|
@ -9,10 +9,10 @@ package disgoman
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"regexp"
|
|
|
|
"strings"
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
"github.com/kballard/go-shellquote"
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// AddCommand adds the Command at the address passed in to the Commands array on the CommandManager.
|
|
|
|
// AddCommand adds the Command at the address passed in to the Commands array on the CommandManager.
|
|
|
|
@ -104,19 +104,11 @@ func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.Mess
|
|
|
|
|
|
|
|
|
|
|
|
var cmd []string
|
|
|
|
var cmd []string
|
|
|
|
// If we found our prefix then remove it and split the command into pieces
|
|
|
|
// If we found our prefix then remove it and split the command into pieces
|
|
|
|
cmd, err = shellquote.Split(strings.TrimPrefix(content, prefix))
|
|
|
|
content = strings.TrimPrefix(content, prefix)
|
|
|
|
if err != nil {
|
|
|
|
r := regexp.MustCompile(`[^\s"]+|"([^"]*)"`)
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
cmd = r.FindAllString(content, -1)
|
|
|
|
if strings.Contains(err.Error(), "Unterminated") {
|
|
|
|
for i, val := range cmd {
|
|
|
|
cmd = strings.Split(strings.TrimPrefix(content, prefix), " ")
|
|
|
|
cmd[i] = strings.Trim(val, "\"")
|
|
|
|
} else {
|
|
|
|
|
|
|
|
c.ErrorChannel <- CommandError{
|
|
|
|
|
|
|
|
Context: ctx,
|
|
|
|
|
|
|
|
Message: "",
|
|
|
|
|
|
|
|
Error: err,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if len(cmd) < 1 {
|
|
|
|
if len(cmd) < 1 {
|
|
|
|
|