From ae0d67f3fdb4f5984e0a12a19b8949463645f18b Mon Sep 17 00:00:00 2001 From: limited_dev Date: Wed, 28 Jun 2023 22:48:46 +0200 Subject: [PATCH] feat: added UpdateRolesExtension for debugging Signed-off-by: limited_dev --- .../extensions/UpdateRolesExtension.kt | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt diff --git a/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt new file mode 100644 index 0000000..109e3c7 --- /dev/null +++ b/src/main/kotlin/net/moonleay/lilJudd/extensions/UpdateRolesExtension.kt @@ -0,0 +1,62 @@ +/* + * lilJudd + * Copyright (C) 2023 moonleay + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.moonleay.lilJudd.extensions + +import com.kotlindiscord.kord.extensions.extensions.Extension +import com.kotlindiscord.kord.extensions.extensions.publicSlashCommand +import com.kotlindiscord.kord.extensions.types.respond +import com.kotlindiscord.kord.extensions.utils.hasPermission +import dev.kord.common.entity.Permission +import dev.kord.gateway.PrivilegedIntent +import net.moonleay.lilJudd.features.AvailabilityManager +import net.moonleay.lilJudd.util.Logger + +class UpdateRolesExtension : Extension() { + override val name = "updateroles" + override val allowApplicationCommandInDMs: Boolean + get() = false + + @OptIn(PrivilegedIntent::class) + override suspend fun setup() { + publicSlashCommand() { + name = "updateroles" + description = "Update the roles of the members in the current server" + this.action { + if (!this.member!!.asMember(this.guild!!.id) + .hasPermission(Permission.Administrator) + ) { + val res = this.respond { + this.content = "no." + } + res.delete() + return@action + } + val res = this.respond { + this.content = "OK." + } + + + // -- below here is the code of the cronjob -- + Logger.out("Starting to update roles...") + + AvailabilityManager.runThread() + } + } + } +}