aboutsummaryrefslogtreecommitdiff
path: root/events.go
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 23:41:33 +0200
committerAnhgelus Morhtuuzh <anhgelus@anhgelus.world>2025-05-13 23:41:33 +0200
commit8f10267e2df7a02ade125f066c17c5fd72ebf159 (patch)
tree0d69b9a000d5de5ca517fa20b0bcf6ae2f267d4a /events.go
parentd10813a97319f6c99327a0b690b0ea54b70483d8 (diff)
style(events): simplify max xp per message
Diffstat (limited to 'events.go')
-rw-r--r--events.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/events.go b/events.go
index 54c444e..cf4c162 100644
--- a/events.go
+++ b/events.go
@@ -35,10 +35,7 @@ func OnMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
trimmed := utils.TrimMessage(strings.ToLower(m.Content))
m.Member.User = m.Author
m.Member.GuildID = m.GuildID
- xp := exp.MessageXP(uint(len(trimmed)), exp.CalcDiversity(trimmed))
- if xp > MaxXpPerMessage {
- xp = MaxXpPerMessage
- }
+ xp := min(exp.MessageXP(uint(len(trimmed)), exp.CalcDiversity(trimmed)), MaxXpPerMessage)
c.AddXP(s, m.Member, xp, func(_ uint, _ uint) {
if err := s.MessageReactionAdd(m.ChannelID, m.Message.ID, "⬆"); err != nil {
utils.SendAlert(
@@ -127,7 +124,7 @@ func onDisconnect(s *discordgo.Session, e *discordgo.VoiceStateUpdate, client *r
// add exp
timeInVocal := now - con
if timeInVocal < 0 {
- utils.SendAlert("events.go - Calculating time spent in vocal", "the time is negative")
+ utils.SendAlert("events.go - Calculating time spent in vocal", "the time is negative", "discord_id", e.UserID, "guild_id", e.GuildID)
return
}
if timeInVocal > MaxTimeInVocal {