From 127ec3147bd27fbd2c7e7a035e48524ff952078d Mon Sep 17 00:00:00 2001 From: limited_dev Date: Sun, 21 May 2023 19:43:53 +0200 Subject: [PATCH] feat: implemented the new TimePlanner Messages With Buttons instead of reactions Signed-off-by: limited_dev --- .../lilJudd/extensions/TestExtension.kt | 1 - .../moonleay/lilJudd/features/TimePlanner.kt | 25 +++++++++++++------ .../net/moonleay/lilJudd/util/MessageUtil.kt | 3 +-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt index 2b98c2f..c6d44c3 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/TestExtension.kt @@ -41,7 +41,6 @@ class TestExtension : Extension() { Color(0X4C4645), "", "MONDAY, 22.05.2023", - "Automated message", mapOf( "Is available" to listOf(), "May be available" to listOf(), diff --git a/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt b/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt index 3cb7bd9..cd23727 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/features/TimePlanner.kt @@ -26,9 +26,11 @@ 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 import net.moonleay.lilJudd.Bot import net.moonleay.lilJudd.data.tables.TimePlanningChannels +import net.moonleay.lilJudd.util.ButtonUtil import net.moonleay.lilJudd.util.Logger import net.moonleay.lilJudd.util.MessageUtil import org.jetbrains.exposed.sql.selectAll @@ -50,7 +52,7 @@ object TimePlanner { suspend fun registerThread() { Logger.out("Adding scheduler...") - val scheduler = buildSchedule("0 0 4 * * * 0o 1w") // 0 0 4 * * * 0o 1 // 0o is UTC + val scheduler = buildSchedule("0 0 4 * * * 0o 1w") // 0 0 4 * * * 0o 1w // 0o is UTC scheduler.doInfinity { Logger.out("Starting to notify...") val channelList = mutableListOf() @@ -77,21 +79,30 @@ object TimePlanner { } delay(3000) var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0) - repeat(6) { + repeat(7) { val m = c.createMessage { this.embeds.add( - MessageUtil.getEmbedSmall( + MessageUtil.getEmbedWithTable( Color(0X4C4645), "", - "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday" + "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday", + mapOf( + "Is available" to listOf(), + "May be available" to listOf(), + "Is not available" to listOf() + ) ) ) + + this.actionRow { + this.components.addAll(ButtonUtil.getTimePlannerButtons().components) + } } then = then.plusDays(1).withHour(20).withMinute(24).withSecond(0) - delay(500) - addReactions(m) - delay(1000) + //delay(500) + //addReactions(m) Logger.out("Finished sending day $it") + delay(1000) } Logger.out("Finished with ${c.data.guildId.value}") } diff --git a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt index c5ca2b8..e6e1c1b 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/util/MessageUtil.kt @@ -89,10 +89,9 @@ object MessageUtil { color: Color, title: String, description: String, - source: String, values: Map>? ): EmbedBuilder { - val ebb = getEmbed(color, title, description, source) + val ebb = getEmbedSmall(color, title, description) if (values != null) for (key in values.keys) { val fb = EmbedBuilder.Field()