more debug

This commit is contained in:
DutchEllie 2021-05-31 11:15:54 +02:00
parent 45b4ec7302
commit 01ba7fafc1
2 changed files with 5 additions and 3 deletions

View File

@ -67,6 +67,7 @@ func (app *application) messageCreate(s *discordgo.Session, m *discordgo.Message
app.findTrigger(s, m)
}
app.infoLog.Printf("Adding entry\n")
app.limiter.LogInteraction(m.Author.ID, "messagecreate")
}

View File

@ -13,14 +13,15 @@ If it is in the limit, then count. If the amount of interactions is higher than
type Limiter struct {
TimeLimit time.Duration
RateLimit int
Logs map[string][]Action
Logs map[string][]*Action
}
func (l *Limiter) LogInteraction(userid string, action string) {
l.Logs[userid] = append(l.Logs[userid], Action{
ac := &Action{
Timestamp: time.Now(),
Type: action,
})
}
l.Logs[userid] = append(l.Logs[userid], ac)
}
/* CheckAllowed counts the amount of log entries for a given userid, making sure to delete and not count the expired ones.