added stop and fixed override
This commit is contained in:
parent
614c0cd42c
commit
810d3aa616
|
@ -40,6 +40,8 @@ func (app *application) messageCreate(s *discordgo.Session, m *discordgo.Message
|
||||||
/* --- Bot commands for words --- */
|
/* --- Bot commands for words --- */
|
||||||
case "pepes":
|
case "pepes":
|
||||||
app.sendManyPepes(s, m, splitCommand)
|
app.sendManyPepes(s, m, splitCommand)
|
||||||
|
case "stop":
|
||||||
|
app.stopRequest(s, m)
|
||||||
/* --- Bot commands, but only admins --- */
|
/* --- Bot commands, but only admins --- */
|
||||||
case "addword":
|
case "addword":
|
||||||
app.addWord(s, m, splitCommand)
|
app.addWord(s, m, splitCommand)
|
||||||
|
|
|
@ -21,6 +21,9 @@ type application struct {
|
||||||
adminroles *mysql.AdminRolesModel
|
adminroles *mysql.AdminRolesModel
|
||||||
trigger string
|
trigger string
|
||||||
allBadWords map[string][]string
|
allBadWords map[string][]string
|
||||||
|
|
||||||
|
active bool
|
||||||
|
stop bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -147,14 +147,35 @@ func (app *application) sendManyPepes(s *discordgo.Session, m *discordgo.Message
|
||||||
|
|
||||||
if (val <= 0 || val > 3) && !override {
|
if (val <= 0 || val > 3) && !override {
|
||||||
s.ChannelMessageSend(m.ChannelID, "The amount has to be > 0 and < 4")
|
s.ChannelMessageSend(m.ChannelID, "The amount has to be > 0 and < 4")
|
||||||
|
return
|
||||||
} else if val <= 0 && override {
|
} 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...")
|
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...")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.active = true
|
||||||
|
|
||||||
for i := 0; i < val; i++ {
|
for i := 0; i < val; i++ {
|
||||||
go app.sendPepe(s, m)
|
if app.stop {
|
||||||
//time.Sleep(time.Millisecond * 500)
|
app.stop = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
app.sendPepe(s, m)
|
||||||
|
time.Sleep(time.Millisecond * 500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.active = false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (app *application) stopRequest(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
if app.active {
|
||||||
|
app.stop = true
|
||||||
|
s.ChannelMessageSend(m.ChannelID, "Emergency stop called, hopefully I stop now")
|
||||||
|
} else {
|
||||||
|
app.stop = false
|
||||||
|
s.ChannelMessageSend(m.ChannelID, "But I wasn't doing anything!")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *application) findTrigger(s *discordgo.Session, m *discordgo.MessageCreate) {
|
func (app *application) findTrigger(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
|
|
Loading…
Reference in New Issue