@@ -11,6 +11,7 @@ import me.ddivad.judgebot.util.*
1111import me.jakejmattson.discordkt.api.dsl.MenuBuilder
1212import me.jakejmattson.discordkt.api.extensions.addField
1313import me.jakejmattson.discordkt.api.extensions.addInlineField
14+ import me.jakejmattson.discordkt.api.extensions.toSnowflake
1415import org.joda.time.DateTime
1516import java.awt.Color
1617import java.text.SimpleDateFormat
@@ -55,25 +56,30 @@ private suspend fun MenuBuilder.buildOverviewPage(
5556
5657 addInlineField(" Record" ,
5758 """
58- ${userRecord.infractions.size} Infaction(s)
59- ${userRecord.notes.size} Note(s)
60- ${userRecord.info.size} Information(s)
59+ **${userRecord.infractions.size} ** Infraction(s)
60+ **${userRecord.notes.size} ** Note(s)
61+ **${userRecord.info.size} ** Information(s)
62+ **${userRecord.deletedMessageCount.deleteReaction} ** Deletes (${config.reactions.deleteMessageReaction} )
6163 """ .trimIndent())
62-
6364 addInlineField(" Points" , " **${userRecord.points} / ${config.infractionConfiguration.pointCeiling} **" )
6465 addInlineField(" History Invokes" , " ${userRecord.historyCount} " )
65- addInlineField(" Creation date" , formatOffsetTime(target.id.timeStamp))
66+
67+ addInlineField(" Created" , formatOffsetTime(target.id.timeStamp))
6668 if (memberInGuild != null ) {
67- addInlineField(" Join date " , formatOffsetTime(memberInGuild.joinedAt))
69+ addInlineField(" Joined " , formatOffsetTime(memberInGuild.joinedAt))
6870 } else addInlineField(" " , " " )
6971
72+ if (userRecord.linkedAccounts.isNotEmpty()) {
73+ addInlineField(" Alts" , userRecord.linkedAccounts.map { guild.kord.getUser(Snowflake (it))?.mention }.joinToString(" \n " ))
74+ }
75+
7076 getStatus(guild, target, databaseService)?.let { addField(" Status" , it) }
7177
7278 if (userRecord.infractions.size > 0 ) {
7379 val lastInfraction = userRecord.infractions[userRecord.infractions.size - 1 ]
7480 addField(
7581 " **__Most Recent Infraction__**" ,
76- " Type: **${lastInfraction.type} ** :: Weight: ** ${lastInfraction.points} **\n " +
82+ " Type: **${lastInfraction.type} ( ${lastInfraction.points} ) **\n " +
7783 " Issued by **${guild.kord.getUser(Snowflake (lastInfraction.moderator))?.username} ** " +
7884 " on **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (lastInfraction.dateTime))} **\n " +
7985 " Punishment: **${lastInfraction.punishment?.punishment} ** ${getDurationText(lastInfraction.punishment)} \n " +
@@ -301,15 +307,29 @@ private suspend fun getStatus(guild: Guild, target: User, databaseService: Datab
301307 return null
302308}
303309
304- suspend fun EmbedBuilder.createSelfHistoryEmbed (target : User ,
305- member : GuildMember ,
310+ suspend fun MenuBuilder.createLinkedAccountMenu (linkedAccountIds : List <String >,
306311 guild : Guild ,
307- config : Configuration ) {
312+ config : Configuration ,
313+ databaseService : DatabaseService ) {
314+ linkedAccountIds.forEach {
315+ val linkedUser = guild.kord.getUser(it.toSnowflake()) ? : return @forEach
316+ val linkedUserRecord = databaseService.users.getOrCreateUser(linkedUser, guild)
317+ page {
318+ createCondensedHistoryEmbed(linkedUser, linkedUserRecord, guild, config)
319+ }
320+ }
321+ }
322+
323+ suspend fun EmbedBuilder.createCondensedHistoryEmbed (target : User ,
324+ member : GuildMember ,
325+ guild : Guild ,
326+ config : Configuration ) {
308327
309328 val userGuildDetails = member.getGuildInfo(guild.id.value)
310329 val infractions = userGuildDetails.infractions
311330 val warnings = userGuildDetails.infractions.filter { it.type == InfractionType .Warn }
312331 val strikes = userGuildDetails.infractions.filter { it.type == InfractionType .Strike }
332+ val notes = userGuildDetails.notes
313333 val maxPoints = config[guild.id.longValue]?.infractionConfiguration?.pointCeiling
314334
315335 color = Color .MAGENTA
@@ -318,37 +338,114 @@ suspend fun EmbedBuilder.createSelfHistoryEmbed(target: User,
318338 url = target.asUser().avatar.url
319339 }
320340 addInlineField(" Infractions" , " ${infractions.size} " )
341+ addInlineField(" Notes" , " ${notes.size} " )
321342 addInlineField(" Points" , " **${member.getPoints(guild)} / $maxPoints **" )
322343
344+ if (notes.isEmpty()) {
345+ addField(" " , " **__Notes__**" )
346+ addField(" No notes recorded." , " " )
347+ } else {
348+ addField(" " , " **__Notes__**" )
349+ notes.forEach { note ->
350+ val moderator = guild.kord.getUser(Snowflake (note.moderator))?.username
351+
352+ addField(
353+ " ID :: ${note.id} :: Staff :: __${moderator} __" ,
354+ " Noted by **${moderator} ** on **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (note.dateTime))} **\n " +
355+ note.note
356+ )
357+ }
358+ }
359+
323360 if (infractions.isEmpty()) {
324- addField(" " , " " )
361+ addField(" " , " **__Infractions__** " )
325362 addField(" No infractions issued." , " " )
326363 } else {
327364 if (warnings.isNotEmpty()) addField(" " , " **__Warnings__**" )
328365 warnings.forEachIndexed { index, infraction ->
329- addField(
330- " ID :: $index :: Weight :: ${infraction.points} " ,
366+ val moderator = guild.kord.getUser(Snowflake (infraction.moderator))?.username
367+ addField(
368+ " ID :: $index :: Staff :: $moderator " ,
331369 " Type: **${infraction.type} (${infraction.points} )** :: " +
332370 " Date: **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (infraction.dateTime))} **\n " +
333371 " Punishment: **${infraction.punishment?.punishment} ** ${
334372 if (infraction.punishment?.duration != null && infraction.punishment?.punishment != = PunishmentType .NONE )
335373 " for **" + timeToString(infraction.punishment?.duration!! ) + " **" else " indefinitely"
336374 } \n " +
337375 infraction.reason
338- )
376+ )
339377 }
340378
341379 if (strikes.isNotEmpty()) addField(" " , " **__Strikes__**" )
342380 strikes.forEachIndexed { index, infraction ->
343- addField(
344- " ID :: $index :: Weight :: ${infraction.points} " ,
381+ val moderator = guild.kord.getUser(Snowflake (infraction.moderator))?.username
382+ addField(
383+ " ID :: $index :: Staff :: $moderator " ,
345384 " Type: **${infraction.type} (${infraction.points} )** :: " +
346385 " Date: **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (infraction.dateTime))} **\n " +
347386 " Punishment: **${infraction.punishment?.punishment} ** ${
348387 if (infraction.punishment?.duration != null && infraction.punishment?.punishment != = PunishmentType .NONE )
349388 " for **" + timeToString(infraction.punishment?.duration!! ) + " **" else " indefinitely"
350389 } \n " +
351390 infraction.reason
391+ )
392+ }
393+ }
394+
395+ footer {
396+ icon = guild.getIconUrl(Image .Format .PNG ) ? : " "
397+ text = guild.name
398+ }
399+ }
400+
401+ suspend fun EmbedBuilder.createSelfHistoryEmbed (target : User ,
402+ member : GuildMember ,
403+ guild : Guild ,
404+ config : Configuration ) {
405+
406+ val userGuildDetails = member.getGuildInfo(guild.id.value)
407+ val infractions = userGuildDetails.infractions
408+ val warnings = userGuildDetails.infractions.filter { it.type == InfractionType .Warn }
409+ val strikes = userGuildDetails.infractions.filter { it.type == InfractionType .Strike }
410+ val maxPoints = config[guild.id.longValue]?.infractionConfiguration?.pointCeiling
411+
412+ color = Color .MAGENTA
413+ title = " ${target.asUser().tag} 's Record"
414+ thumbnail {
415+ url = target.asUser().avatar.url
416+ }
417+ addInlineField(" Infractions" , " ${infractions.size} " )
418+ addInlineField(" Points" , " **${member.getPoints(guild)} / $maxPoints **" )
419+
420+ if (infractions.isEmpty()) {
421+ addField(" " , " " )
422+ addField(" No infractions issued." , " " )
423+ } else {
424+ if (warnings.isNotEmpty()) addField(" " , " **__Warnings__**" )
425+ warnings.forEachIndexed { index, infraction ->
426+ addField(
427+ " ID :: $index :: Weight :: ${infraction.points} " ,
428+ " Type: **${infraction.type} (${infraction.points} )** :: " +
429+ " Date: **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (infraction.dateTime))} **\n " +
430+ " Punishment: **${infraction.punishment?.punishment} ** ${
431+ if (infraction.punishment?.duration != null && infraction.punishment?.punishment != = PunishmentType .NONE )
432+ " for **" + timeToString(infraction.punishment?.duration!! ) + " **" else " indefinitely"
433+ } \n " +
434+ infraction.reason
435+ )
436+ }
437+
438+ if (strikes.isNotEmpty()) addField(" " , " **__Strikes__**" )
439+ strikes.forEachIndexed { index, infraction ->
440+ addField(
441+ " ID :: $index :: Weight :: ${infraction.points} " ,
442+ " Type: **${infraction.type} (${infraction.points} )** :: " +
443+ " Date: **${SimpleDateFormat (" dd/MM/yyyy" ).format(Date (infraction.dateTime))} **\n " +
444+ " Punishment: **${infraction.punishment?.punishment} ** ${
445+ if (infraction.punishment?.duration != null && infraction.punishment?.punishment != = PunishmentType .NONE )
446+ " for **" + timeToString(infraction.punishment?.duration!! ) + " **" else " indefinitely"
447+ } \n " +
448+ infraction.reason
352449 )
353450 }
354451 }
0 commit comments