Skip to content

Commit 9e4f41c

Browse files
committed
fix: update sorting for strikes / notes & change infraction embed
1 parent 5c399ce commit 9e4f41c

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/main/kotlin/me/ddivad/judgebot/embeds/InfractionEmbeds.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ fun EmbedBuilder.createInfractionEmbed(guild: Guild, configuration: GuildConfigu
1818

1919
fun EmbedBuilder.createWarnEmbed(guild: Guild, configuration: GuildConfiguration, user: User, guildMember: GuildMember, infraction: Infraction, rule: Rule?) {
2020
title = "Warn"
21-
description = """
22-
| ${user.mention}, you have received a **warning** from **${guild.name}**. A warning is a way for staff to inform you that your behaviour needs to change or further infractions will follow.
23-
| If you think this to be unjustified, please **do not** post about it in a public channel but take it up with **Modmail**.
24-
""".trimMargin()
21+
description = "${user.mention}, you have received a **warning** from **${guild.name}**."
22+
23+
field {
24+
name = "__Reason__"
25+
value = infraction.reason
26+
inline = false
27+
}
2528

2629
if (infraction.ruleNumber != null) {
2730
field {
@@ -30,12 +33,6 @@ fun EmbedBuilder.createWarnEmbed(guild: Guild, configuration: GuildConfiguration
3033
}
3134
}
3235

33-
field {
34-
name = "__Reason__"
35-
value = infraction.reason
36-
inline = true
37-
}
38-
3936
if (configuration.infractionConfiguration.warnPoints > 0) {
4037
field {
4138
name = "__Points__"
@@ -50,6 +47,14 @@ fun EmbedBuilder.createWarnEmbed(guild: Guild, configuration: GuildConfiguration
5047
}
5148
}
5249

50+
field {
51+
name = ""
52+
value = """
53+
A warning is a way for staff to inform you that your behaviour needs to change or further infractions will follow.
54+
If you think this to be unjustified, please **do not** post about it in a public channel but DM **Modmail**.
55+
""".trimIndent()
56+
}
57+
5358
color = Color.RED
5459
thumbnail {
5560
url = guild.getIconUrl(Image.Format.PNG) ?: ""

src/main/kotlin/me/ddivad/judgebot/embeds/UserEmbeds.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ private suspend fun MenuBuilder.buildOverviewPage(
7676
getStatus(guild, target, databaseService)?.let { addField("Status", it) }
7777

7878
if (userRecord.infractions.size > 0) {
79-
val lastInfraction = userRecord.infractions[userRecord.infractions.size - 1]
79+
val lastInfraction = userRecord.infractions.sortedByDescending { it.dateTime }[0]
80+
8081
addField(
8182
"**__Most Recent Infraction__**",
8283
"Type: **${lastInfraction.type} (${lastInfraction.points})**\n " +
@@ -106,8 +107,8 @@ private suspend fun MenuBuilder.buildInfractionPage(
106107
thumbnail {
107108
url = target.asUser().avatar.url
108109
}
109-
val warnings = userRecord.infractions.filter { it.type == InfractionType.Warn }
110-
val strikes = userRecord.infractions.filter { it.type == InfractionType.Strike }
110+
val warnings = userRecord.infractions.filter { it.type == InfractionType.Warn }.sortedByDescending { it.dateTime }
111+
val strikes = userRecord.infractions.filter { it.type == InfractionType.Strike }.sortedByDescending { it.dateTime }
111112
val bans = userRecord.infractions.filter { it.punishment?.punishment == PunishmentType.BAN }
112113

113114
addInlineField("Warns", "${warnings.size}")
@@ -154,7 +155,7 @@ private suspend fun MenuBuilder.buildNotesPages(
154155
embedColor: Color,
155156
totalPages: Int
156157
) {
157-
val paginatedNotes = userRecord.notes.chunked(4)
158+
val paginatedNotes = userRecord.notes.sortedByDescending { it.dateTime }.chunked(4)
158159
if (userRecord.notes.isEmpty()) {
159160
page {
160161
color = embedColor

0 commit comments

Comments
 (0)