mirror of
https://github.com/devproje/px32-bot.git
synced 2024-11-29 20:13:06 +00:00
fix: plugin unload issue fixed
This commit is contained in:
parent
e9f17fcd78
commit
b526a5ef57
2 changed files with 9 additions and 11 deletions
|
@ -19,8 +19,6 @@ object Info : GlobalCommand {
|
||||||
val r = Runtime.getRuntime()
|
val r = Runtime.getRuntime()
|
||||||
|
|
||||||
val size = kernel.plugins.size
|
val size = kernel.plugins.size
|
||||||
val hSize = kernel.handlers.size
|
|
||||||
|
|
||||||
val info = """
|
val info = """
|
||||||
Px32Bot v${DefaultConfig.version}, JDA `v${JDAInfo.VERSION}`,
|
Px32Bot v${DefaultConfig.version}, JDA `v${JDAInfo.VERSION}`,
|
||||||
`Java ${System.getProperty("java.version")}` and `Kotlin ${KotlinVersion.CURRENT}` System on `${System.getProperty("os.name")}`
|
`Java ${System.getProperty("java.version")}` and `Kotlin ${KotlinVersion.CURRENT}` System on `${System.getProperty("os.name")}`
|
||||||
|
@ -32,7 +30,6 @@ object Info : GlobalCommand {
|
||||||
Using `${(r.totalMemory() - r.freeMemory()) / 1048576}MB` at this Bot
|
Using `${(r.totalMemory() - r.freeMemory()) / 1048576}MB` at this Bot
|
||||||
|
|
||||||
Total $size plugin${if (size > 1) "s" else ""} loaded
|
Total $size plugin${if (size > 1) "s" else ""} loaded
|
||||||
Total $hSize handler${if (hSize > 1) "s" else ""} used
|
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
ev.reply(info).queue()
|
ev.reply(info).queue()
|
||||||
|
|
|
@ -24,18 +24,19 @@ class CoreKernel(token: String) {
|
||||||
private set
|
private set
|
||||||
|
|
||||||
private val builder = JDABuilder.createDefault(token, listOf(
|
private val builder = JDABuilder.createDefault(token, listOf(
|
||||||
GatewayIntent.GUILD_PRESENCES,
|
|
||||||
GatewayIntent.GUILD_MEMBERS,
|
GatewayIntent.GUILD_MEMBERS,
|
||||||
GatewayIntent.GUILD_MESSAGES,
|
GatewayIntent.GUILD_MESSAGES,
|
||||||
GatewayIntent.MESSAGE_CONTENT,
|
GatewayIntent.MESSAGE_CONTENT,
|
||||||
|
GatewayIntent.GUILD_PRESENCES,
|
||||||
|
GatewayIntent.SCHEDULED_EVENTS,
|
||||||
GatewayIntent.GUILD_VOICE_STATES,
|
GatewayIntent.GUILD_VOICE_STATES,
|
||||||
GatewayIntent.GUILD_EMOJIS_AND_STICKERS,
|
GatewayIntent.GUILD_EMOJIS_AND_STICKERS
|
||||||
GatewayIntent.SCHEDULED_EVENTS
|
|
||||||
)).setMemberCachePolicy(MemberCachePolicy.ALL)
|
)).setMemberCachePolicy(MemberCachePolicy.ALL)
|
||||||
|
|
||||||
val memLock = Mutex()
|
val memLock = Mutex()
|
||||||
val commandContainer = CommandHandler()
|
val commandContainer = CommandHandler()
|
||||||
val plugins = mutableMapOf<PluginConfig, Plugin>()
|
var plugins = mutableMapOf<PluginConfig, Plugin>()
|
||||||
|
private set
|
||||||
var isActive = false
|
var isActive = false
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
@ -133,10 +134,10 @@ class CoreKernel(token: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy()
|
destroy()
|
||||||
logger.info(jda.eventManager.registeredListeners.size.toString())
|
plugins = mutableMapOf()
|
||||||
|
|
||||||
|
include()
|
||||||
load()
|
load()
|
||||||
logger.info(jda.eventManager.registeredListeners.size.toString())
|
|
||||||
|
|
||||||
plugins.forEach { (_, plugin) ->
|
plugins.forEach { (_, plugin) ->
|
||||||
plugin.handlers.forEach {
|
plugin.handlers.forEach {
|
||||||
|
@ -144,8 +145,6 @@ class CoreKernel(token: String) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(jda.eventManager.registeredListeners.size.toString())
|
|
||||||
|
|
||||||
handlers.filterIsInstance<CommandHandler>().forEach { h ->
|
handlers.filterIsInstance<CommandHandler>().forEach { h ->
|
||||||
h.register(jda)
|
h.register(jda)
|
||||||
}
|
}
|
||||||
|
@ -210,6 +209,8 @@ class CoreKernel(token: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
include()
|
include()
|
||||||
|
load()
|
||||||
|
|
||||||
plugins.forEach { (_, plugin) ->
|
plugins.forEach { (_, plugin) ->
|
||||||
plugin.handlers.forEach { handler ->
|
plugin.handlers.forEach { handler ->
|
||||||
logger.info("Load event listener: ${handler::class.simpleName}")
|
logger.info("Load event listener: ${handler::class.simpleName}")
|
||||||
|
|
Loading…
Reference in a new issue