diff --git a/src/main/kotlin/me/ddivad/judgebot/Main.kt b/src/main/kotlin/me/ddivad/judgebot/Main.kt index 5e9c7e2..64c658b 100644 --- a/src/main/kotlin/me/ddivad/judgebot/Main.kt +++ b/src/main/kotlin/me/ddivad/judgebot/Main.kt @@ -69,7 +69,7 @@ suspend fun main() { field { name = "Build Info" value = "```" + - "Version: 2.7.0\n" + + "Version: 2.7.1\n" + "DiscordKt: ${versions.library}\n" + "Kord: ${versions.kord}\n" + "Kotlin: $kotlinVersion" + diff --git a/src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt b/src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt index 75c0412..aee7ac0 100644 --- a/src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt +++ b/src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt @@ -114,11 +114,14 @@ data class GuildMember( suspend fun checkPointDecay(guild: Guild, configuration: GuildConfiguration, loggingService: LoggingService) = with(this.getGuildInfo(guild.id.toString())) { val weeksSincePointsDecayed = Weeks.weeksBetween(DateTime(this.pointDecayTimer), DateTime()).weeks if (weeksSincePointsDecayed > 0) { - val pointsToRemove = configuration.infractionConfiguration.pointDecayPerWeek * weeksSincePointsDecayed - this.points -= pointsToRemove - if (this.points < 0) this.points = 0 + if (this.points > 0) { + val pointsToRemove = configuration.infractionConfiguration.pointDecayPerWeek * weeksSincePointsDecayed + if (pointsToRemove > this.points) { + this.points = 0 + } else this.points -= pointsToRemove + loggingService.pointDecayApplied(guild, this@GuildMember, this.points, pointsToRemove, weeksSincePointsDecayed) + } this.pointDecayTimer = DateTime().millis - loggingService.pointDecayApplied(guild, this@GuildMember, this.points, pointsToRemove, weeksSincePointsDecayed) } } diff --git a/src/main/kotlin/me/ddivad/judgebot/services/LoggingService.kt b/src/main/kotlin/me/ddivad/judgebot/services/LoggingService.kt index 5c1941c..241b702 100644 --- a/src/main/kotlin/me/ddivad/judgebot/services/LoggingService.kt +++ b/src/main/kotlin/me/ddivad/judgebot/services/LoggingService.kt @@ -84,8 +84,8 @@ class LoggingService(private val configuration: Configuration) { log( guild, - "**Info ::** Infraction Points for ${user?.descriptor()} " + - "reduced by **$pointsDeducted** to **$newPoints** " + + "**Info ::** Infraction point decay for ${user?.descriptor()} " + + "\nPoints reduced by **$pointsDeducted** to **$newPoints** " + "for **$weeksSinceLastInfraction** infraction free weeks." ) }