style(events): simplify max xp per message
This commit is contained in:
parent
d10813a973
commit
8f10267e2d
1 changed files with 2 additions and 5 deletions
|
@ -35,10 +35,7 @@ func OnMessage(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
trimmed := utils.TrimMessage(strings.ToLower(m.Content))
|
trimmed := utils.TrimMessage(strings.ToLower(m.Content))
|
||||||
m.Member.User = m.Author
|
m.Member.User = m.Author
|
||||||
m.Member.GuildID = m.GuildID
|
m.Member.GuildID = m.GuildID
|
||||||
xp := exp.MessageXP(uint(len(trimmed)), exp.CalcDiversity(trimmed))
|
xp := min(exp.MessageXP(uint(len(trimmed)), exp.CalcDiversity(trimmed)), MaxXpPerMessage)
|
||||||
if xp > MaxXpPerMessage {
|
|
||||||
xp = MaxXpPerMessage
|
|
||||||
}
|
|
||||||
c.AddXP(s, m.Member, xp, func(_ uint, _ uint) {
|
c.AddXP(s, m.Member, xp, func(_ uint, _ uint) {
|
||||||
if err := s.MessageReactionAdd(m.ChannelID, m.Message.ID, "⬆"); err != nil {
|
if err := s.MessageReactionAdd(m.ChannelID, m.Message.ID, "⬆"); err != nil {
|
||||||
utils.SendAlert(
|
utils.SendAlert(
|
||||||
|
@ -127,7 +124,7 @@ func onDisconnect(s *discordgo.Session, e *discordgo.VoiceStateUpdate, client *r
|
||||||
// add exp
|
// add exp
|
||||||
timeInVocal := now - con
|
timeInVocal := now - con
|
||||||
if timeInVocal < 0 {
|
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
|
return
|
||||||
}
|
}
|
||||||
if timeInVocal > MaxTimeInVocal {
|
if timeInVocal > MaxTimeInVocal {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue