fix: fixed issue with the TimePlanners formatting

chore: cleaned up TimePlanner code

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-05-28 16:04:37 +02:00
parent 0b5e386057
commit 40cf95c43d
2 changed files with 11 additions and 18 deletions

View file

@ -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<MessageChannel>(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)
}
}

View file

@ -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")
}