feat: improved replaceXWithYinValuesAtTable function, edited MatchButtons

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-09-11 12:45:51 +02:00
parent 5431515976
commit 8dd123fe44
Signed by: moonleay
GPG key ID: 82667543CCD715FB

View file

@ -41,17 +41,26 @@ object EmbedUtil {
fun getMatchButtons(): ActionRowBuilder { fun getMatchButtons(): ActionRowBuilder {
val ar = ActionRowBuilder() val ar = ActionRowBuilder()
ar.interactionButton(ButtonStyle.Success, "public.edit.btn.matchmanagement.accept") { 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") { ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.matchmanagement.decline") {
this.label = "Cancel" this.label = "I'm out!"
} }
/*
ar.interactionButton(ButtonStyle.Secondary, "public.edit.btn.matchmanagement.cancel") {
this.label = "Cancel this match..."
} */
return ar return ar
} }
fun replaceXWithYinValuesAtTable(x: String, y: String, e: Embed, table: Int): EmbedBuilder { fun replaceXWithYinValuesAtTable(x: String, y: String, e: Embed, table: Int): EmbedBuilder {
val ebb = MessageUtil.getAClonedEmbedd(e) return replaceXWithYinValuesAtTable(x, y, MessageUtil.getAClonedEmbed(e), table)
for ((i, f) in e.fields.withIndex()) { }
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() val fb = EmbedBuilder.Field()
fb.name = f.name fb.name = f.name
if (i == table - 1) { if (i == table - 1) {
@ -66,9 +75,9 @@ object EmbedUtil {
} else } else
fb.value = f.value fb.value = f.value
fb.inline = true fb.inline = true
ebb.fields.add(fb) ebbb.fields.add(fb)
} }
return ebb return ebbb
} }
fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List<String> { fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List<String> {
@ -87,8 +96,13 @@ object EmbedUtil {
} }
fun addXToValuesAtTable(x: String, e: Embed, table: Int): EmbedBuilder { fun addXToValuesAtTable(x: String, e: Embed, table: Int): EmbedBuilder {
val ebb = MessageUtil.getAClonedEmbedd(e) return addXToValuesAtTable(x, MessageUtil.getAClonedEmbed(e), table)
for ((i, f) in e.fields.withIndex()) { }
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() val fb = EmbedBuilder.Field()
fb.name = f.name fb.name = f.name
if (i == table - 1) if (i == table - 1)
@ -105,9 +119,9 @@ object EmbedUtil {
} }
fb.inline = true fb.inline = true
ebb.fields.add(fb) ebbb.fields.add(fb)
} }
return ebb return ebbb
} }
} }