From 40cf95c43d45e7a8f55499eeec0d51c07b2ce184 Mon Sep 17 00:00:00 2001 From: limited_dev Date: Sun, 28 May 2023 16:04:37 +0200 Subject: [PATCH] fix: fixed issue with the TimePlanners formatting chore: cleaned up TimePlanner code Signed-off-by: limited_dev --- .../moonleay/lilJudd/features/TimePlanner.kt | 17 ++--------------- .../net/moonleay/lilJudd/util/ButtonUtil.kt | 12 +++++++++--- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt index ed877b6..a8bb189 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt @@ -18,13 +18,11 @@ package net.moonleay.lilJudd.features -import com.kotlindiscord.kord.extensions.utils.addReaction import dev.inmo.krontab.buildSchedule import dev.inmo.krontab.doInfinity import dev.kord.common.Color import dev.kord.common.entity.Snowflake import dev.kord.core.behavior.channel.createMessage -import dev.kord.core.entity.Message import dev.kord.core.entity.channel.MessageChannel import dev.kord.rest.builder.message.create.actionRow import kotlinx.coroutines.delay @@ -65,7 +63,7 @@ object TimePlanner { Logger.out("${channelList.count()} Channels to notify!") for (ch in channelList) { if (Bot.bot.kordRef.getChannel(ch) == null) - continue // TODO: Remove from DB + continue // TODO: Check if the channel is valid in another shard val c = Bot.bot.kordRef.getChannelOf(ch)!! c.createMessage { this.embeds.add( @@ -80,7 +78,7 @@ object TimePlanner { delay(3000) var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0) repeat(7) { - val m = c.createMessage { + c.createMessage { this.embeds.add( MessageUtil.getEmbedWithTable( Color(0X4C4645), @@ -99,8 +97,6 @@ object TimePlanner { } } then = then.plusDays(1).withHour(20).withMinute(24).withSecond(0) - //delay(500) - //addReactions(m) Logger.out("Finished sending day $it") delay(1000) } @@ -109,13 +105,4 @@ object TimePlanner { Logger.out("Done! Until next Monday! <3 ") } } - - private suspend fun addReactions(msg: Message) { - msg.addReaction("✅") - delay(300) - msg.addReaction("❌") - delay(300) - msg.addReaction("❓") - delay(300) - } } diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt index 5abda22..a172965 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/ButtonUtil.kt @@ -45,9 +45,12 @@ object ButtonUtil { fb.name = f.name if (i == table - 1) { val v = f.value.split("\n").toMutableList() - for ((i, l) in v.withIndex()) + for ((j, l) in v.withIndex()) if (l.contains(x)) - v[i] = "\n${y}" + v[j] = y + v.removeIf { + !it.contains("@") + } fb.value = v.joinToString("\n") } else fb.value = f.value @@ -68,7 +71,10 @@ object ButtonUtil { val v = f.value.split("\n").toMutableList() for ((j, l) in v.withIndex()) if (l.contains(x)) - v[j] = "\n" + v[j] = "" + v.removeIf { + !it.contains("@") + } fb.value = v.joinToString("\n") }