diff --git a/discord/simple.go b/discord/simple.go index cfacc43..ac6fdf5 100644 --- a/discord/simple.go +++ b/discord/simple.go @@ -112,32 +112,48 @@ func (app *application) sendGithub(s *discordgo.Session, m *discordgo.MessageCre } func (app *application) sendManyPepes(s *discordgo.Session, m *discordgo.MessageCreate, splitCommand []string) { - /* Check if admin */ - r, err := app.checkIfAdmin(s, m) - if err != nil { - app.errorLog.Print(err) - return - } - if !r { - return - } - + override := false + + /* [0] is !pepe, [1] is pepes, [2] is amount, [3] is override*/ + if len(splitCommand) <= 2 { app.errorLog.Printf("many pepes command had no numeral argument") - s.ChannelMessageSend(m.ChannelID, "This command requires a numeral as a second argument, which is between 1 and 10") + s.ChannelMessageSend(m.ChannelID, "This command requires a numeral as a second argument, which is between 1 and 3") return } + if len(splitCommand) > 3 { + if splitCommand[3] == "override" { + /* Check if admin */ + r, err := app.checkIfAdmin(s, m) + if err != nil { + app.errorLog.Print(err) + return + } + if r { + //s.ChannelMessageSend(m.ChannelID, "You have to be admin to override, not overriding") + override = true + } + + } + } + val, err := strconv.Atoi(splitCommand[2]) - if err != nil || val > 10 || val <= 0 { + if err != nil { app.errorLog.Printf("many pepes command had a non-numeral as argument") - s.ChannelMessageSend(m.ChannelID, "This command requires a numeral as a second argument, which is between 1 and 10") + s.ChannelMessageSend(m.ChannelID, "This command requires a numeral as a second argument") return } + if (val <= 0 || val > 3) && !override { + s.ChannelMessageSend(m.ChannelID, "The amount has to be > 0 and < 4") + } else if val <= 0 && override { + s.ChannelMessageSend(m.ChannelID, "I know you're admin and all, but you still have to provide a positive integer amount of pepes to send...") + } + for i := 0; i < val; i++ { - app.sendPepe(s, m) - time.Sleep(time.Millisecond * 500) + go app.sendPepe(s, m) + //time.Sleep(time.Millisecond * 500) } }