From e4afe685f7ed1001fb2b0b6610b8bf76e7a40039 Mon Sep 17 00:00:00 2001 From: Project_IO Date: Sun, 8 Sep 2024 19:29:27 +0900 Subject: [PATCH] feat: middle save --- .../net/wh64/p/x32/GlobalCommandHandler.kt | 14 +++++++++++++- .../net/wh64/p/x32/SlashCommandExecutor.kt | 18 ++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/px32-bot-core/src/main/kotlin/net/wh64/p/x32/GlobalCommandHandler.kt b/px32-bot-core/src/main/kotlin/net/wh64/p/x32/GlobalCommandHandler.kt index 388d235..4f11585 100644 --- a/px32-bot-core/src/main/kotlin/net/wh64/p/x32/GlobalCommandHandler.kt +++ b/px32-bot-core/src/main/kotlin/net/wh64/p/x32/GlobalCommandHandler.kt @@ -1,5 +1,17 @@ package net.wh64.p.x32 -class GlobalCommandHandler { +import net.dv8tion.jda.api.events.interaction.command.MessageContextInteractionEvent +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent +import net.dv8tion.jda.api.events.interaction.command.UserContextInteractionEvent +import net.dv8tion.jda.api.hooks.ListenerAdapter +class GlobalCommandHandler : ListenerAdapter() { + override fun onSlashCommandInteraction(event: SlashCommandInteractionEvent) { + } + + override fun onUserContextInteraction(event: UserContextInteractionEvent) { + } + + override fun onMessageContextInteraction(event: MessageContextInteractionEvent) { + } } \ No newline at end of file diff --git a/px32-bot-core/src/main/kotlin/net/wh64/p/x32/SlashCommandExecutor.kt b/px32-bot-core/src/main/kotlin/net/wh64/p/x32/SlashCommandExecutor.kt index a525d7d..8139280 100644 --- a/px32-bot-core/src/main/kotlin/net/wh64/p/x32/SlashCommandExecutor.kt +++ b/px32-bot-core/src/main/kotlin/net/wh64/p/x32/SlashCommandExecutor.kt @@ -19,3 +19,21 @@ interface MessageContextExecutor { val data: CommandData fun execute(ev: MessageContextInteractionEvent) } + +abstract class CommandAdapter : SlashCommandExecutor, UserContextExecutor, MessageContextExecutor { + abstract override val data: CommandData + + override fun execute(ev: SlashCommandInteractionEvent) { + executor(ev) + } + + override fun execute(ev: UserContextInteractionEvent) { + executor(ev) + } + + override fun execute(ev: MessageContextInteractionEvent) { + executor(ev) + } + + abstract fun executor(ev: Any) +}