mirror of
https://github.com/devproje/px32-bot.git
synced 2025-04-19 22:59:53 +09:00
Compare commits
3 commits
1.0.0-beta
...
master
Author | SHA1 | Date | |
---|---|---|---|
5a13eb5376 | |||
a48e25b33e | |||
6cad37f299 |
5 changed files with 21 additions and 16 deletions
|
@ -6,7 +6,7 @@
|
||||||
- [Github](https://github.com/devproje/px32-bot.git)
|
- [Github](https://github.com/devproje/px32-bot.git)
|
||||||
|
|
||||||
## How to Use
|
## How to Use
|
||||||
봇 구동기는 [이곳](https://gitlab.wh64.net/devproje/px32-bot/-/releases)에서 다운로드 받으실 수 있습니다.
|
봇 구동기는 [이곳](https://github.com/devproje/px32-bot/releases)에서 다운로드 받으실 수 있습니다.
|
||||||
|
|
||||||
## Developments
|
## Developments
|
||||||
API를 사용하여 플러그인 개발을 원하신다면 아래의 코드로 라이브러리를 추가 해 주세요.
|
API를 사용하여 플러그인 개발을 원하신다면 아래의 코드로 라이브러리를 추가 해 주세요.
|
||||||
|
|
|
@ -2,7 +2,7 @@ kotlin.code.style=official
|
||||||
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-Xmx2048M -Dfile.encoding=UTF-8
|
||||||
|
|
||||||
group=net.projecttl
|
group=net.projecttl
|
||||||
version=1.0.0-beta.1
|
version=1.0.0-beta.3
|
||||||
|
|
||||||
ktor_version=2.3.12
|
ktor_version=2.3.12
|
||||||
log4j_version=2.23.1
|
log4j_version=2.23.1
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package net.projecttl.p.x32.api.command
|
package net.projecttl.p.x32.api.command
|
||||||
|
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.Command
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType
|
import net.dv8tion.jda.api.interactions.commands.OptionType
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
import net.dv8tion.jda.api.interactions.commands.build.OptionData
|
||||||
|
@ -122,7 +123,13 @@ class OptionObj {
|
||||||
var required: Boolean = false
|
var required: Boolean = false
|
||||||
var autoComplete: Boolean = false
|
var autoComplete: Boolean = false
|
||||||
|
|
||||||
|
var choices = mutableListOf<Command.Choice>()
|
||||||
|
|
||||||
fun build(): OptionData {
|
fun build(): OptionData {
|
||||||
return OptionData(type, name, description, required, autoComplete)
|
return OptionData(type, name, description, required, autoComplete).apply {
|
||||||
|
this@OptionObj.choices.forEach {
|
||||||
|
addChoices(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,19 @@ fun main(args: Array<out String>) {
|
||||||
if (args.contains("--remove-cmd")) {
|
if (args.contains("--remove-cmd")) {
|
||||||
jda = kernel.build()
|
jda = kernel.build()
|
||||||
try {
|
try {
|
||||||
jda.retrieveCommands().queue {
|
val list = jda.retrieveCommands().complete()
|
||||||
if (it == null) {
|
if (list.isEmpty()) {
|
||||||
return@queue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
it.forEach { command ->
|
list.forEach { command ->
|
||||||
logger.info("unregister command: /${command.name}")
|
logger.info("unregister command: /${command.name}")
|
||||||
command.jda.deleteCommandById(command.id).queue()
|
command.jda.deleteCommandById(command.id).complete()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
ex.printStackTrace()
|
ex.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel.kill()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,10 @@ class CoreKernel(token: String) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun kill() {
|
fun kill() {
|
||||||
|
isActive = false
|
||||||
|
|
||||||
destroy()
|
destroy()
|
||||||
|
logger.info("shutdown now Px32 kernel v${DefaultConfig.version}")
|
||||||
jda.shutdownNow()
|
jda.shutdownNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,10 +213,7 @@ class CoreKernel(token: String) {
|
||||||
isActive = true
|
isActive = true
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(Thread {
|
Runtime.getRuntime().addShutdownHook(Thread {
|
||||||
isActive = false
|
kill()
|
||||||
|
|
||||||
logger.info("shutdown now Px32 kernel v${DefaultConfig.version}")
|
|
||||||
jda.shutdownNow()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return jda
|
return jda
|
||||||
|
|
Loading…
Reference in a new issue