mirror of
https://github.com/devproje/px32-bot.git
synced 2024-11-29 20:13:06 +00:00
fix: optimized import
This commit is contained in:
parent
be4e62ab7e
commit
e9a57c9f6a
6 changed files with 14 additions and 6 deletions
|
@ -2,7 +2,6 @@ package net.projecttl.p.x32.api
|
|||
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||
import net.projecttl.p.x32.api.command.CommandHandler
|
||||
import net.projecttl.p.x32.api.model.PluginConfig
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
|
|
@ -11,6 +11,10 @@ object Reload : GlobalCommand {
|
|||
override val data = CommandData.fromData(CommandDataImpl("reload", "플러그인을 다시 불러 옵니다").toData())
|
||||
|
||||
override suspend fun execute(ev: SlashCommandInteractionEvent) {
|
||||
if (kernel.memLock) {
|
||||
return
|
||||
}
|
||||
|
||||
if (ev.user.id != Config.owner) {
|
||||
return ev.reply(":warning: 권한을 가지고 있지 않아요").queue()
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
package net.projecttl.p.x32.kernel
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.dv8tion.jda.api.JDA
|
||||
import net.dv8tion.jda.api.JDABuilder
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||
import net.projecttl.p.x32.api.Plugin
|
||||
import net.projecttl.p.x32.api.command.CommandHandler
|
||||
import net.projecttl.p.x32.api.model.PluginConfig
|
||||
import net.projecttl.p.x32.config.Config
|
||||
import net.projecttl.p.x32.func.General
|
||||
import net.projecttl.p.x32.jda
|
||||
|
||||
class CoreKernel(token: String) {
|
||||
var memLock = false
|
||||
private set
|
||||
private val builder = JDABuilder.createDefault(token)
|
||||
private val handlers = mutableListOf<ListenerAdapter>()
|
||||
private val commandContainer = CommandHandler()
|
||||
|
@ -70,6 +70,10 @@ class CoreKernel(token: String) {
|
|||
}
|
||||
|
||||
fun reload() {
|
||||
if (!memLock) {
|
||||
memLock = true
|
||||
}
|
||||
|
||||
val newHandlers = mutableListOf<ListenerAdapter>()
|
||||
PluginLoader.destroy()
|
||||
plugins().forEach { plugin ->
|
||||
|
@ -102,5 +106,7 @@ class CoreKernel(token: String) {
|
|||
h.register(jda)
|
||||
}
|
||||
}
|
||||
|
||||
memLock = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.projecttl.p.x32.kernel
|
||||
|
||||
import kotlinx.serialization.json.Json
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||
import net.projecttl.p.x32.api.Plugin
|
||||
import net.projecttl.p.x32.api.model.PluginConfig
|
||||
import net.projecttl.p.x32.logger
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package net.projecttl.p.x32.func
|
||||
|
||||
import net.dv8tion.jda.api.JDABuilder
|
||||
import net.projecttl.p.x32.api.Plugin
|
||||
import net.projecttl.p.x32.api.command.CommandHandler
|
||||
import net.projecttl.p.x32.func.command.Avatar
|
||||
import net.projecttl.p.x32.func.command.MsgPurge
|
||||
import net.projecttl.p.x32.func.command.MsgLength
|
||||
import net.projecttl.p.x32.func.command.MsgPurge
|
||||
import net.projecttl.p.x32.func.command.Ping
|
||||
import net.projecttl.p.x32.func.handler.Ready
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package net.projecttl.p.x32.func.command
|
||||
|
||||
import Conf
|
||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData
|
||||
|
|
Loading…
Reference in a new issue