From 9885466ed580aa8b1e1d00338699a61f01332adb Mon Sep 17 00:00:00 2001 From: limited_dev Date: Thu, 15 Jun 2023 08:07:15 +0200 Subject: [PATCH] !fix: removed not properly usable sendplanner command Signed-off-by: limited_dev --- .../extensions/SendPlannerExtension.kt | 67 ++++++++----------- 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt index 4d3defb..2482bbf 100644 --- a/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/SendPlannerExtension.kt @@ -18,8 +18,6 @@ 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.publicSlashCommand import com.kotlindiscord.kord.extensions.types.respond @@ -44,11 +42,11 @@ class SendPlannerExtension : Extension() { get() = false override suspend fun setup() { - publicSlashCommand(::PlannerArgs) { + publicSlashCommand() { name = "sendplanner" description = "Send the planner for the current and x next weeks" this.action { - if (this.arguments.weeks == 0 || !this.member!!.asMember(this.guild!!.id) + if (!this.member!!.asMember(this.guild!!.id) .hasPermission(Permission.Administrator) ) { val res = this.respond { @@ -65,42 +63,39 @@ class SendPlannerExtension : Extension() { var then = ZonedDateTime.now(ZoneId.of("Europe/Berlin")).withDayOfMonth(getMondayDayOfMonth()).withHour(4) .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 { this.embeds.add( - MessageUtil.getEmbed( + MessageUtil.getEmbedWithTable( Color(0X4C4645), - "Time Planning Feature", - "Do you have time on the following Days?", - "Automated Message" - ) - ) - } - 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() - ) + "", + "${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) - } + this.actionRow { + 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}") } @@ -112,12 +107,4 @@ class SendPlannerExtension : Extension() { val monday = now.with(DayOfWeek.MONDAY) 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 - } - } }