feat: added UpdateRolesExtension for debugging
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
fb287b24cf
commit
ae0d67f3fd
1 changed files with 62 additions and 0 deletions
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue