Fall back to split on spaces if unterminated quote error

master v0.0.1
DustyP 6 years ago
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,
c.ErrorChannel <- CommandError{ Invoked: "",
Context: ctx, ErrorChannel: c.ErrorChannel,
Message: "", }
Error: err, c.ErrorChannel <- CommandError{
Context: ctx,
Message: "",
Error: err,
}
return
} }
return
} }
var command *Command var command *Command

Loading…
Cancel
Save