Skip to content

Commit

Permalink
Merge pull request #132 from the-programmers-hangout/develop
Browse files Browse the repository at this point in the history
chore: merge develop for v2.7.1
  • Loading branch information
ddivad195 authored Jan 6, 2022
2 parents e1bb224 + 4ee8b0a commit d513c8d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/me/ddivad/judgebot/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
11 changes: 7 additions & 4 deletions src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/me/ddivad/judgebot/services/LoggingService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
}
Expand Down

0 comments on commit d513c8d

Please sign in to comment.