From 8dd123fe44a57848a634167dcab0cf7375e1eccf Mon Sep 17 00:00:00 2001 From: moonleay Date: Mon, 11 Sep 2023 12:45:51 +0200 Subject: [PATCH] feat: improved replaceXWithYinValuesAtTable function, edited MatchButtons Signed-off-by: moonleay --- .../net/moonleay/lilJudd/util/EmbedUtil.kt | 36 +++++++++++++------ 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt index d367709..e9dbbaf 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt @@ -41,17 +41,26 @@ object EmbedUtil { fun getMatchButtons(): ActionRowBuilder { val ar = ActionRowBuilder() ar.interactionButton(ButtonStyle.Success, "public.edit.btn.matchmanagement.accept") { - this.label = "Sign me up!" + this.label = "I'm in!" } - ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.matchmanagement.cancel") { - this.label = "Cancel" + ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.matchmanagement.decline") { + this.label = "I'm out!" } + /* + ar.interactionButton(ButtonStyle.Secondary, "public.edit.btn.matchmanagement.cancel") { + this.label = "Cancel this match..." + } */ return ar } fun replaceXWithYinValuesAtTable(x: String, y: String, e: Embed, table: Int): EmbedBuilder { - val ebb = MessageUtil.getAClonedEmbedd(e) - for ((i, f) in e.fields.withIndex()) { + return replaceXWithYinValuesAtTable(x, y, MessageUtil.getAClonedEmbed(e), table) + } + + fun replaceXWithYinValuesAtTable(x: String, y: String, ebb: EmbedBuilder, table: Int): EmbedBuilder { + val ebbb = MessageUtil.getAClonedEmbed(ebb) + ebbb.fields = mutableListOf() + for ((i, f) in ebb.fields.withIndex()) { val fb = EmbedBuilder.Field() fb.name = f.name if (i == table - 1) { @@ -66,9 +75,9 @@ object EmbedUtil { } else fb.value = f.value fb.inline = true - ebb.fields.add(fb) + ebbb.fields.add(fb) } - return ebb + return ebbb } fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List { @@ -87,8 +96,13 @@ object EmbedUtil { } fun addXToValuesAtTable(x: String, e: Embed, table: Int): EmbedBuilder { - val ebb = MessageUtil.getAClonedEmbedd(e) - for ((i, f) in e.fields.withIndex()) { + return addXToValuesAtTable(x, MessageUtil.getAClonedEmbed(e), table) + } + + fun addXToValuesAtTable(x: String, ebb: EmbedBuilder, table: Int): EmbedBuilder { + val ebbb = MessageUtil.getAClonedEmbed(ebb) + ebbb.fields = mutableListOf() + ebb.fields.forEachIndexed { i, f -> val fb = EmbedBuilder.Field() fb.name = f.name if (i == table - 1) @@ -105,9 +119,9 @@ object EmbedUtil { } fb.inline = true - ebb.fields.add(fb) + ebbb.fields.add(fb) } - return ebb + return ebbb } }