Fall back to split on spaces if unterminated quote error
This commit is contained in:
parent
4add5bffa3
commit
b493499897
@ -90,25 +90,30 @@ func (c *CommandManager) OnMessage(session *discordgo.Session, m *discordgo.Mess
|
|||||||
|
|
||||||
guild, _ := session.Guild(m.GuildID)
|
guild, _ := session.Guild(m.GuildID)
|
||||||
|
|
||||||
|
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))
|
cmd, err = shellquote.Split(strings.TrimPrefix(content, prefix))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx := Context{
|
if err.Error() == "Unterminated double-quoted string" || err.Error() == "Unterminated single-quoted string" {
|
||||||
Session: session,
|
cmd = strings.Split(strings.TrimPrefix(content, prefix), " ")
|
||||||
Channel: channel,
|
} else {
|
||||||
Message: m.Message,
|
ctx := Context{
|
||||||
User: m.Author,
|
Session: session,
|
||||||
Guild: guild,
|
Channel: channel,
|
||||||
Member: m.Member,
|
Message: m.Message,
|
||||||
Invoked: "",
|
User: m.Author,
|
||||||
ErrorChannel: c.ErrorChannel,
|
Guild: guild,
|
||||||
|
Member: m.Member,
|
||||||
|
Invoked: "",
|
||||||
|
ErrorChannel: c.ErrorChannel,
|
||||||
|
}
|
||||||
|
c.ErrorChannel <- CommandError{
|
||||||
|
Context: ctx,
|
||||||
|
Message: "",
|
||||||
|
Error: err,
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
c.ErrorChannel <- CommandError{
|
|
||||||
Context: ctx,
|
|
||||||
Message: "",
|
|
||||||
Error: err,
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var command *Command
|
var command *Command
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user