HOTFIX: message intent added

This commit is contained in:
Project_IO 2024-09-27 21:27:40 +09:00
parent 74fb7c7e04
commit 75a3b73993
5 changed files with 24 additions and 5 deletions

View file

@ -2,7 +2,7 @@ kotlin.code.style=official
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
group=net.projecttl
version=0.2.0-SNAPSHOT
version=0.2.1-SNAPSHOT
ktor_version=2.3.12
log4j_version=2.23.1

View file

@ -6,10 +6,20 @@ import net.projecttl.p.x32.api.model.PluginConfig
import net.projecttl.p.x32.api.util.AsyncTaskContainer
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
abstract class Plugin {
private val handlerContainer = mutableListOf<ListenerAdapter>()
val taskContainer = AsyncTaskContainer()
val pluginDataDir: File
get() {
val f = File("plugins/${config.name}")
if (!f.exists()) {
f.mkdirs()
}
return f
}
val config = this.javaClass.getResourceAsStream("/plugin.json")!!.let {
val raw = it.bufferedReader().readText()

View file

@ -6,10 +6,10 @@ import net.dv8tion.jda.api.JDA
import net.dv8tion.jda.api.JDABuilder
import net.dv8tion.jda.api.hooks.ListenerAdapter
import net.dv8tion.jda.api.requests.GatewayIntent
import net.dv8tion.jda.api.utils.MemberCachePolicy
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.api.util.AsyncTaskContainer
import net.projecttl.p.x32.config.Config
import net.projecttl.p.x32.func.BundleModule
import net.projecttl.p.x32.logger
@ -22,11 +22,12 @@ class CoreKernel(token: String) {
private val builder = JDABuilder.createDefault(token, listOf(
GatewayIntent.GUILD_PRESENCES,
GatewayIntent.GUILD_MEMBERS,
GatewayIntent.GUILD_MESSAGES,
GatewayIntent.MESSAGE_CONTENT,
GatewayIntent.GUILD_VOICE_STATES,
GatewayIntent.GUILD_EMOJIS_AND_STICKERS,
GatewayIntent.SCHEDULED_EVENTS
))
)).setMemberCachePolicy(MemberCachePolicy.ALL)
private val handlers = mutableListOf<ListenerAdapter>()
private val commandContainer = CommandHandler()
@ -159,6 +160,8 @@ class CoreKernel(token: String) {
}
fun destroy() {
val unloaded = mutableListOf<PluginConfig>()
plugins.forEach { (config, plugin) ->
logger.info("disable ${config.name} plugin...")
@ -168,6 +171,12 @@ class CoreKernel(token: String) {
logger.error("failed to destroy ${config.name} plugin")
ex.printStackTrace()
}
unloaded += config
}
unloaded.forEach {
plugins.remove(it)
}
}

View file

@ -1 +1 @@
version=${project.version}
version=${rootProject.version}

View file

@ -1,6 +1,6 @@
{
"name": "bundle-module",
"version": "${project.version}",
"version": "${rootProject.version}",
"main": "net.projecttl.p.x32.func.BundleModule"
}