From 69a3b27bce5dfdff042dbda39645c2f6228d6103 Mon Sep 17 00:00:00 2001 From: ddivad195 Date: Wed, 16 Jun 2021 11:44:06 +0100 Subject: [PATCH 1/3] fix: add validation for rule id in infraction conversation --- .../judgebot/conversations/InfractionConversation.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt b/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt index c1caf04..83b6513 100644 --- a/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt +++ b/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt @@ -22,7 +22,14 @@ class InfractionConversation(private val databaseService: DatabaseService, else guildConfiguration.infractionConfiguration.warnPoints val rules = databaseService.guilds.getRules(guild) val ruleId = if (rules.isNotEmpty()) { - val rule = promptEmbed(IntegerArg) { createInfractionRuleEmbed(guild, rules) } + respond { createInfractionRuleEmbed(guild, rules) } +// val rule = promptEmbed(IntegerArg) { createInfractionRuleEmbed(guild, rules) } + val rule = promptUntil( + IntegerArg, + prompt = "Enter choice:", + isValid = { number -> rules.any { it.number == number } || number == 0 }, + error = "Rule not found. Please enter a valid rule ID or 0:" + ) if (rule > 0) rule else null } else null val infraction = Infraction(this.user.id.value, infractionReason, type, points, ruleId) From b15cd602d8f7a213dbff2f3c48d12a12928f7914 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 16 Jun 2021 11:46:48 +0100 Subject: [PATCH 2/3] chore: bump version --- src/main/kotlin/me/ddivad/judgebot/Main.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/me/ddivad/judgebot/Main.kt b/src/main/kotlin/me/ddivad/judgebot/Main.kt index 97ea366..9ecbcfc 100644 --- a/src/main/kotlin/me/ddivad/judgebot/Main.kt +++ b/src/main/kotlin/me/ddivad/judgebot/Main.kt @@ -57,7 +57,7 @@ suspend fun main(args: Array) { field { name = "Build Info" value = "```" + - "Version: 2.1.1\n" + + "Version: 2.1.2\n" + "DiscordKt: ${versions.library}\n" + "Kotlin: $kotlinVersion" + "```" From c7fbab6323dd9c2ae9d5a30dbbcf1b079414cb54 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 16 Jun 2021 11:48:54 +0100 Subject: [PATCH 3/3] chore: remove commented code --- .../me/ddivad/judgebot/conversations/InfractionConversation.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt b/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt index 83b6513..c9cbdc7 100644 --- a/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt +++ b/src/main/kotlin/me/ddivad/judgebot/conversations/InfractionConversation.kt @@ -23,7 +23,6 @@ class InfractionConversation(private val databaseService: DatabaseService, val rules = databaseService.guilds.getRules(guild) val ruleId = if (rules.isNotEmpty()) { respond { createInfractionRuleEmbed(guild, rules) } -// val rule = promptEmbed(IntegerArg) { createInfractionRuleEmbed(guild, rules) } val rule = promptUntil( IntegerArg, prompt = "Enter choice:", @@ -36,4 +35,4 @@ class InfractionConversation(private val databaseService: DatabaseService, infractionService.infract(targetUser, guild, user, infraction) respondMenu { createHistoryEmbed(targetUser, user, guild, configuration, databaseService) } } -} \ No newline at end of file +}