feat: implemented the new TimePlanner Messages With Buttons instead of reactions
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
433641484d
commit
127ec3147b
3 changed files with 19 additions and 10 deletions
|
@ -41,7 +41,6 @@ class TestExtension : Extension() {
|
||||||
Color(0X4C4645),
|
Color(0X4C4645),
|
||||||
"",
|
"",
|
||||||
"MONDAY, 22.05.2023",
|
"MONDAY, 22.05.2023",
|
||||||
"Automated message",
|
|
||||||
mapOf(
|
mapOf(
|
||||||
"Is available" to listOf(),
|
"Is available" to listOf(),
|
||||||
"May be available" to listOf(),
|
"May be available" to listOf(),
|
||||||
|
|
|
@ -26,9 +26,11 @@ import dev.kord.common.entity.Snowflake
|
||||||
import dev.kord.core.behavior.channel.createMessage
|
import dev.kord.core.behavior.channel.createMessage
|
||||||
import dev.kord.core.entity.Message
|
import dev.kord.core.entity.Message
|
||||||
import dev.kord.core.entity.channel.MessageChannel
|
import dev.kord.core.entity.channel.MessageChannel
|
||||||
|
import dev.kord.rest.builder.message.create.actionRow
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import net.moonleay.lilJudd.Bot
|
import net.moonleay.lilJudd.Bot
|
||||||
import net.moonleay.lilJudd.data.tables.TimePlanningChannels
|
import net.moonleay.lilJudd.data.tables.TimePlanningChannels
|
||||||
|
import net.moonleay.lilJudd.util.ButtonUtil
|
||||||
import net.moonleay.lilJudd.util.Logger
|
import net.moonleay.lilJudd.util.Logger
|
||||||
import net.moonleay.lilJudd.util.MessageUtil
|
import net.moonleay.lilJudd.util.MessageUtil
|
||||||
import org.jetbrains.exposed.sql.selectAll
|
import org.jetbrains.exposed.sql.selectAll
|
||||||
|
@ -50,7 +52,7 @@ object TimePlanner {
|
||||||
|
|
||||||
suspend fun registerThread() {
|
suspend fun registerThread() {
|
||||||
Logger.out("Adding scheduler...")
|
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 {
|
scheduler.doInfinity {
|
||||||
Logger.out("Starting to notify...")
|
Logger.out("Starting to notify...")
|
||||||
val channelList = mutableListOf<Snowflake>()
|
val channelList = mutableListOf<Snowflake>()
|
||||||
|
@ -77,21 +79,30 @@ object TimePlanner {
|
||||||
}
|
}
|
||||||
delay(3000)
|
delay(3000)
|
||||||
var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0)
|
var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withHour(4).withMinute(0).withSecond(0)
|
||||||
repeat(6) {
|
repeat(7) {
|
||||||
val m = c.createMessage {
|
val m = c.createMessage {
|
||||||
this.embeds.add(
|
this.embeds.add(
|
||||||
MessageUtil.getEmbedSmall(
|
MessageUtil.getEmbedWithTable(
|
||||||
Color(0X4C4645),
|
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)
|
then = then.plusDays(1).withHour(20).withMinute(24).withSecond(0)
|
||||||
delay(500)
|
//delay(500)
|
||||||
addReactions(m)
|
//addReactions(m)
|
||||||
delay(1000)
|
|
||||||
Logger.out("Finished sending day $it")
|
Logger.out("Finished sending day $it")
|
||||||
|
delay(1000)
|
||||||
}
|
}
|
||||||
Logger.out("Finished with ${c.data.guildId.value}")
|
Logger.out("Finished with ${c.data.guildId.value}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,10 +89,9 @@ object MessageUtil {
|
||||||
color: Color,
|
color: Color,
|
||||||
title: String,
|
title: String,
|
||||||
description: String,
|
description: String,
|
||||||
source: String,
|
|
||||||
values: Map<String, List<String>>?
|
values: Map<String, List<String>>?
|
||||||
): EmbedBuilder {
|
): EmbedBuilder {
|
||||||
val ebb = getEmbed(color, title, description, source)
|
val ebb = getEmbedSmall(color, title, description)
|
||||||
if (values != null)
|
if (values != null)
|
||||||
for (key in values.keys) {
|
for (key in values.keys) {
|
||||||
val fb = EmbedBuilder.Field()
|
val fb = EmbedBuilder.Field()
|
||||||
|
|
Loading…
Reference in a new issue