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 {
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<String> {
@ -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
}
}