mirror of
https://github.com/dalbodeule/chibot-chzzk-bot.git
synced 2025-06-09 07:18:22 +00:00
Merge pull request #7 from dalbodeule/develop
add guild update, update document, update version to 1.0.1
This commit is contained in:
commit
cec07f9859
14
README.md
14
README.md
@ -21,13 +21,27 @@
|
|||||||
- [x] /register chzzk_id: \[치지직 고유ID]
|
- [x] /register chzzk_id: \[치지직 고유ID]
|
||||||
- [x] /alert channel: \[디스코드 Channel ID] content: \[알림 내용]
|
- [x] /alert channel: \[디스코드 Channel ID] content: \[알림 내용]
|
||||||
- [x] /add label: \[명령어] content: \[내용]
|
- [x] /add label: \[명령어] content: \[내용]
|
||||||
|
- [ ] /list
|
||||||
- [x] /update label: \[명령어] content: \[내용]
|
- [x] /update label: \[명령어] content: \[내용]
|
||||||
- [x] /delete label: \[명령어]
|
- [x] /delete label: \[명령어]
|
||||||
|
### 매니저 명령어 (on Discord)
|
||||||
|
- [x] /addmanager user: \[Discord user]
|
||||||
|
- [x] /listmanager
|
||||||
|
- [x] /removemanager user: \[Discord user]
|
||||||
### 관리 명령어 (on Chzzk chat)
|
### 관리 명령어 (on Chzzk chat)
|
||||||
- [x] !명령어추가 \[명령어] \[내용]
|
- [x] !명령어추가 \[명령어] \[내용]
|
||||||
- [x] !명령어수정 \[명령어] \[내용]
|
- [x] !명령어수정 \[명령어] \[내용]
|
||||||
- [x] !명령어삭제 \[명령어]
|
- [x] !명령어삭제 \[명령어]
|
||||||
|
|
||||||
|
### Envs
|
||||||
|
- DISCORD_TOKEN
|
||||||
|
- DB_URL
|
||||||
|
- DB_USER
|
||||||
|
- DB_PASS
|
||||||
|
- RUN_AGENT = `false`
|
||||||
|
- NID_AUT
|
||||||
|
- NID_SES
|
||||||
|
|
||||||
### 사용 예시
|
### 사용 예시
|
||||||
- 팔로우
|
- 팔로우
|
||||||
- `/add label: !팔로우 content: <name>님은 오늘로 <following>일째 팔로우네요!`
|
- `/add label: !팔로우 content: <name>님은 오늘로 <following>일째 팔로우네요!`
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
group = space.mori
|
group = space.mori
|
||||||
version = 1.0.0
|
version = 1.0.1
|
||||||
|
|
||||||
org.gradle.jvmargs=-Dfile.encoding=UTF-8
|
org.gradle.jvmargs=-Dfile.encoding=UTF-8
|
||||||
org.gradle.console=plain
|
org.gradle.console=plain
|
||||||
|
@ -4,6 +4,7 @@ import net.dv8tion.jda.api.JDA
|
|||||||
import net.dv8tion.jda.api.JDABuilder
|
import net.dv8tion.jda.api.JDABuilder
|
||||||
import net.dv8tion.jda.api.entities.Activity
|
import net.dv8tion.jda.api.entities.Activity
|
||||||
import net.dv8tion.jda.api.entities.Guild
|
import net.dv8tion.jda.api.entities.Guild
|
||||||
|
import net.dv8tion.jda.api.events.guild.GuildJoinEvent
|
||||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent
|
import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent
|
||||||
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
import net.dv8tion.jda.api.hooks.ListenerAdapter
|
||||||
@ -40,6 +41,26 @@ class Discord: ListenerAdapter() {
|
|||||||
event.member?.let { ManagerService.deleteManager(event.guild.idLong, it.idLong) }
|
event.member?.let { ManagerService.deleteManager(event.guild.idLong, it.idLong) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onGuildJoin(event: GuildJoinEvent) {
|
||||||
|
commandUpdate(event.guild)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun commandUpdate(guild: Guild) {
|
||||||
|
guild.updateCommands().addCommands(* commands.map { it.command}.toTypedArray())
|
||||||
|
.onSuccess {
|
||||||
|
logger.info("Command update on guild success!")
|
||||||
|
}
|
||||||
|
.queue()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun commandUpdate(bot: JDA) {
|
||||||
|
bot.updateCommands().addCommands(* commands.map { it.command}.toTypedArray())
|
||||||
|
.onSuccess {
|
||||||
|
logger.info("Command update bot boot success!")
|
||||||
|
}
|
||||||
|
.queue()
|
||||||
|
}
|
||||||
|
|
||||||
internal fun enable() {
|
internal fun enable() {
|
||||||
val thread = Thread {
|
val thread = Thread {
|
||||||
try {
|
try {
|
||||||
@ -50,18 +71,9 @@ class Discord: ListenerAdapter() {
|
|||||||
|
|
||||||
guild = bot.getGuildById(dotenv["GUILD_ID"])
|
guild = bot.getGuildById(dotenv["GUILD_ID"])
|
||||||
|
|
||||||
bot.updateCommands()
|
commandUpdate(bot)
|
||||||
.addCommands(* commands.map { it.command }.toTypedArray())
|
bot.guilds.forEach {
|
||||||
.onSuccess {
|
commandUpdate(it)
|
||||||
logger.info("Command update success!")
|
|
||||||
logger.debug("Command list: ${commands.joinToString("/ ") { it.name }}")
|
|
||||||
}
|
|
||||||
.queue()
|
|
||||||
|
|
||||||
|
|
||||||
if (guild == null) {
|
|
||||||
logger.info("No guild found!")
|
|
||||||
this.disable()
|
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
logger.info("Could not enable Discord!")
|
logger.info("Could not enable Discord!")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user