Fall back to split on spaces if unterminated quote error
This commit is contained in:
parent
4add5bffa3
commit
b493499897
@ -90,9 +90,13 @@ func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.Mess
|
||||
|
||||
guild, _ := session.Guild(m.GuildID)
|
||||
|
||||
var cmd []string
|
||||
// If we found our prefix then remove it and split the command into pieces
|
||||
cmd, err := shellquote.Split(strings.TrimPrefix(content, prefix))
|
||||
cmd, err = shellquote.Split(strings.TrimPrefix(content, prefix))
|
||||
if err != nil {
|
||||
if err.Error() == "Unterminated double-quoted string" || err.Error() == "Unterminated single-quoted string" {
|
||||
cmd = strings.Split(strings.TrimPrefix(content, prefix), " ")
|
||||
} else {
|
||||
ctx := Context{
|
||||
Session: session,
|
||||
Channel: channel,
|
||||
@ -110,6 +114,7 @@ func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.Mess
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var command *Command
|
||||
invoked := cmd[0]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user