|
|
|
@ -25,6 +25,9 @@ func RecalculateEverything(dg *discordgo.Session, guildID string) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
listOfMessages := make(map[string][]*discordgo.Message)
|
|
|
|
|
latestMessage := make(map[string]string)
|
|
|
|
|
for {
|
|
|
|
|
newMessagesFound := false
|
|
|
|
|
for _, v := range guild.Channels {
|
|
|
|
|
if persistent.IgnoredChannels[v.ID] {
|
|
|
|
|
continue
|
|
|
|
@ -36,19 +39,33 @@ func RecalculateEverything(dg *discordgo.Session, guildID string) {
|
|
|
|
|
util.ReportError(dg, err)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if beforeID == "" && len(messages) > 0 && messages[0].ID != latestMessage[v.ID] {
|
|
|
|
|
newMessagesFound = true
|
|
|
|
|
latestMessage[v.ID] = messages[0].ID
|
|
|
|
|
}
|
|
|
|
|
dupe := false
|
|
|
|
|
for _, msg := range messages {
|
|
|
|
|
if msg.ID == latestMessage[v.ID] {
|
|
|
|
|
dupe = true
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
if list, ok := listOfMessages[msg.Author.ID]; ok {
|
|
|
|
|
listOfMessages[msg.Author.ID] = append(list, msg)
|
|
|
|
|
} else {
|
|
|
|
|
listOfMessages[msg.Author.ID] = []*discordgo.Message{msg}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if len(messages) < 100 {
|
|
|
|
|
if len(messages) < 100 || dupe {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
beforeID = messages[99].ID
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fmt.Printf("[RECALC] Batch step reached in %v.\n", time.Now().Sub(startTime))
|
|
|
|
|
if !newMessagesFound {
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fetchedTime := time.Now()
|
|
|
|
|
totalXP := make(map[string]int64)
|
|
|
|
|
for k, v := range listOfMessages {
|
|
|
|
|