diff --git a/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt b/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt index 9c6929c..3c7e8cb 100644 --- a/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt +++ b/px32-bot-api/src/main/kotlin/net/projecttl/p/x32/api/Plugin.kt @@ -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 diff --git a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Reload.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Reload.kt index ccfcc7f..0d2af47 100644 --- a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Reload.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/command/Reload.kt @@ -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() } diff --git a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt index 8fe33b4..17b3527 100644 --- a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/CoreKernel.kt @@ -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() private val commandContainer = CommandHandler() @@ -70,6 +70,10 @@ class CoreKernel(token: String) { } fun reload() { + if (!memLock) { + memLock = true + } + val newHandlers = mutableListOf() PluginLoader.destroy() plugins().forEach { plugin -> @@ -102,5 +106,7 @@ class CoreKernel(token: String) { h.register(jda) } } + + memLock = false } } diff --git a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/PluginLoader.kt b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/PluginLoader.kt index 4427b13..5ee1015 100644 --- a/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/PluginLoader.kt +++ b/px32-bot-core/src/main/kotlin/net/projecttl/p/x32/kernel/PluginLoader.kt @@ -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 diff --git a/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/General.kt b/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/General.kt index 2575a50..c4913af 100644 --- a/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/General.kt +++ b/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/General.kt @@ -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 diff --git a/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/command/MsgPurge.kt b/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/command/MsgPurge.kt index 7d0965e..dcee12d 100644 --- a/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/command/MsgPurge.kt +++ b/px32-bot-module/src/main/kotlin/net/projecttl/p/x32/func/command/MsgPurge.kt @@ -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