Skip to content

Commit a341785

Browse files
authored
Merge pull request #115 from the-programmers-hangout/develop
release: merge develop with master
2 parents f2ba5ac + d2b48d0 commit a341785

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/main/kotlin/me/ddivad/judgebot/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ suspend fun main(args: Array<String>) {
6767
field {
6868
name = "Build Info"
6969
value = "```" +
70-
"Version: 2.4.0\n" +
70+
"Version: 2.4.1\n" +
7171
"DiscordKt: ${versions.library}\n" +
7272
"Kotlin: $kotlinVersion" +
7373
"```"

src/main/kotlin/me/ddivad/judgebot/dataclasses/GuildMember.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,17 @@ data class GuildMember(
9999
infraction.id = nextId
100100
this.infractions.add(infraction)
101101
this.points += infraction.points
102-
this.pointDecayTimer = DateTime().millis.plus(infraction.punishment?.duration ?: 0)
103102
this.lastInfraction = DateTime().millis
104103
}
105104

106105
fun incrementHistoryCount(guildId: String) {
107106
this.getGuildInfo(guildId).historyCount += 1
108107
}
109108

109+
fun updatePointDecayDate(guild: Guild, punishmentDuration: Long) = with(this.getGuildInfo(guild.id.asString)) {
110+
this.pointDecayTimer = DateTime().millis.plus(punishmentDuration)
111+
}
112+
110113
fun addMessageDeleted(guild: Guild, deleteReaction: Boolean) = with(this.getGuildInfo(guild.id.asString)) {
111114
this.deletedMessageCount.total++
112115
if (deleteReaction) this.deletedMessageCount.deleteReaction++

src/main/kotlin/me/ddivad/judgebot/services/database/UserOperations.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ class UserOperations(
8686
}
8787

8888
suspend fun addInfraction(guild: Guild, user: GuildMember, infraction: Infraction): Infraction {
89-
infraction.punishment = getPunishmentForPoints(guild, user)
9089
user.addInfraction(infraction, guild)
90+
infraction.punishment = getPunishmentForPoints(guild, user)
91+
user.updatePointDecayDate(guild, infraction.punishment?.duration ?: 0)
9192
this.updateUser(user)
9293
return infraction
9394
}

0 commit comments

Comments
 (0)