!fix: removed not properly usable sendplanner command

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-15 08:07:15 +02:00
parent 8bebe08b15
commit 9885466ed5

View file

@ -18,8 +18,6 @@
package net.moonleay.lilJudd.extensions package net.moonleay.lilJudd.extensions
import com.kotlindiscord.kord.extensions.commands.Arguments
import com.kotlindiscord.kord.extensions.commands.converters.impl.int
import com.kotlindiscord.kord.extensions.extensions.Extension import com.kotlindiscord.kord.extensions.extensions.Extension
import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand
import com.kotlindiscord.kord.extensions.types.respond import com.kotlindiscord.kord.extensions.types.respond
@ -44,11 +42,11 @@ class SendPlannerExtension : Extension() {
get() = false get() = false
override suspend fun setup() { override suspend fun setup() {
publicSlashCommand(::PlannerArgs) { publicSlashCommand() {
name = "sendplanner" name = "sendplanner"
description = "Send the planner for the current and x next weeks" description = "Send the planner for the current and x next weeks"
this.action { this.action {
if (this.arguments.weeks == 0 || !this.member!!.asMember(this.guild!!.id) if (!this.member!!.asMember(this.guild!!.id)
.hasPermission(Permission.Administrator) .hasPermission(Permission.Administrator)
) { ) {
val res = this.respond { val res = this.respond {
@ -65,42 +63,39 @@ class SendPlannerExtension : Extension() {
var then = var then =
ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(getMondayDayOfMonth()).withHour(4) ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(getMondayDayOfMonth()).withHour(4)
.withMinute(0).withSecond(0) .withMinute(0).withSecond(0)
repeat(this.arguments.weeks) { c.createMessage {
this.embeds.add(
MessageUtil.getEmbed(
Color(0X4C4645),
"Time Planning Feature",
"Do you have time on the following Days?",
"Automated Message"
)
)
}
delay(1000)
repeat(7) {
c.createMessage { c.createMessage {
this.embeds.add( this.embeds.add(
MessageUtil.getEmbed( MessageUtil.getEmbedWithTable(
Color(0X4C4645), Color(0X4C4645),
"Time Planning Feature", "",
"Do you have time on the following Days?", "${then.dayOfWeek.name}, ${then.dayOfMonth}.${then.monthValue}.${then.year} /${it + 1}. weekday",
"Automated Message" mapOf(
) "Is available" to listOf(),
) "May be available" to listOf(),
} "Is not available" to listOf()
delay(1000)
repeat(7) {
c.createMessage {
this.embeds.add(
MessageUtil.getEmbedWithTable(
Color(0X4C4645),
"",
"${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.actionRow {
this.components.addAll(ButtonUtil.getTimePlannerButtons().components) this.components.addAll(ButtonUtil.getTimePlannerButtons().components)
}
} }
then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
Logger.out("Finished sending day $it")
delay(1000)
} }
Logger.out("Finished week $it") then = then.plusDays(1).withHour(4).withMinute(0).withSecond(0)
Logger.out("Finished sending day $it")
delay(1000)
} }
Logger.out("Finished with ${c.data.guildId.value}") Logger.out("Finished with ${c.data.guildId.value}")
} }
@ -112,12 +107,4 @@ class SendPlannerExtension : Extension() {
val monday = now.with(DayOfWeek.MONDAY) val monday = now.with(DayOfWeek.MONDAY)
return monday.dayOfMonth return monday.dayOfMonth
} }
inner class PlannerArgs : Arguments() {
val weeks by int {
name = "weeks"
description = "Amount of weeks to send. Needs to be at least 1."
minValue = 1
}
}
} }