From 4bc2fe69301aa03c4b45672776c432bf9826b643 Mon Sep 17 00:00:00 2001 From: limited_dev Date: Wed, 28 Jun 2023 22:40:27 +0200 Subject: [PATCH] feat: added get Users in the first X fields fix: fixed typo in May be available button chore: renamed ButtonUtil to EmbedUtil Signed-off-by: limited_dev --- .../util/{ButtonUtil.kt => EmbedUtil.kt} | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) rename src/main/kotlin/net/moonleay/lilJudd/util/{ButtonUtil.kt => EmbedUtil.kt} (82%) diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt similarity index 82% rename from src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt rename to src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt index a172965..831d4e7 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/EmbedUtil.kt @@ -23,14 +23,14 @@ import dev.kord.core.entity.Embed import dev.kord.rest.builder.component.ActionRowBuilder import dev.kord.rest.builder.message.EmbedBuilder -object ButtonUtil { +object EmbedUtil { fun getTimePlannerButtons(): ActionRowBuilder { val ar = ActionRowBuilder() ar.interactionButton(ButtonStyle.Success, "public.edit.btn.timemanagement.available") { this.label = "Available" } ar.interactionButton(ButtonStyle.Primary, "public.edit.btn.timemanagement.maybeavailable") { - this.label = "Maybe available" + this.label = "May be available" } ar.interactionButton(ButtonStyle.Danger, "public.edit.btn.timemanagement.notavailable") { this.label = "Not available" @@ -60,6 +60,21 @@ object ButtonUtil { return ebb } + fun getAllUsersInTheFirstXTables(amountOfTables: Int, e: Embed): List { + val users = mutableListOf() + for (i in 0 until amountOfTables - 1) { + val f = e.fields[i] + if (!f.value.contains("@")) + continue // check next one. this one does not have any entries + val v = f.value.split("\n").toMutableList() + for (l in v) { + Logger.out(l) + users.add(l.subSequence(2, l.indexOf(">")).toString()) + } + } + return users + } + fun addXToValuesAtTable(x: String, e: Embed, table: Int): EmbedBuilder { val ebb = MessageUtil.getAClonedEmbedd(e) for ((i, f) in e.fields.withIndex()) {