From cde28d1a18c5dac138ac4eefee218f79d4df312c Mon Sep 17 00:00:00 2001 From: NovaFox161 Date: Tue, 21 Sep 2021 22:07:03 -0500 Subject: [PATCH] Update to latest D4J snapshot --- .../discal/client/DisCalClient.kt | 4 ++-- .../discal/client/commands/AddCalCommand.kt | 4 ++-- .../discal/client/commands/DevCommand.kt | 14 ++++++------- .../discal/client/commands/DiscalCommand.kt | 4 ++-- .../discal/client/commands/EventsCommand.kt | 12 +++++------ .../discal/client/commands/HelpCommand.kt | 4 ++-- .../client/commands/LinkCalendarCommand.kt | 4 ++-- .../discal/client/commands/RsvpCommand.kt | 20 +++++++++---------- .../discal/client/commands/SettingsCommand.kt | 16 +++++++-------- .../discal/client/commands/SlashCommand.kt | 4 ++-- .../discal/client/commands/TimeCommand.kt | 4 ++-- .../listeners/discord/SlashCommandListener.kt | 4 ++-- .../network/discord/GlobalCommandRegistrar.kt | 7 ++++++- 13 files changed, 53 insertions(+), 48 deletions(-) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/DisCalClient.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/DisCalClient.kt index 9658a3d7..e86eac0e 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/DisCalClient.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/DisCalClient.kt @@ -6,7 +6,7 @@ import discord4j.core.DiscordClientBuilder import discord4j.core.GatewayDiscordClient import discord4j.core.`object`.presence.ClientActivity import discord4j.core.`object`.presence.ClientPresence -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import discord4j.core.event.domain.lifecycle.ReadyEvent import discord4j.core.event.domain.message.MessageCreateEvent import discord4j.core.event.domain.role.RoleDeleteEvent @@ -108,7 +108,7 @@ class DisCalClient { val slashCommandListener = SlashCommandListener(spring) val onSlashCommand = client - .on(SlashCommandEvent::class.java, slashCommandListener::handle) + .on(ChatInputInteractionEvent::class.java, slashCommandListener::handle) .then() val startAnnouncement = Flux.interval(Duration.ofMinutes(5)) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/AddCalCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/AddCalCommand.kt index dadcc2c4..1d7a35b1 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/AddCalCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/AddCalCommand.kt @@ -2,7 +2,7 @@ package org.dreamexposure.discal.client.commands import discord4j.core.`object`.entity.Guild import discord4j.core.`object`.entity.Member -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.core.`object`.BotSettings import org.dreamexposure.discal.core.`object`.GuildSettings @@ -17,7 +17,7 @@ class AddCalCommand : SlashCommand { override val name = "addcal" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { //TODO: Remove dev-only and switch to patron-only once this is completed return if (settings.devGuild) { Mono.justOrEmpty(event.interaction.member) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DevCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DevCommand.kt index de018a5f..9db3ac53 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DevCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DevCommand.kt @@ -2,7 +2,7 @@ package org.dreamexposure.discal.client.commands import discord4j.common.util.Snowflake import discord4j.core.`object`.command.ApplicationCommandInteractionOptionValue -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.core.`object`.GuildSettings import org.dreamexposure.discal.core.`object`.web.UserAPIAccount @@ -18,7 +18,7 @@ class DevCommand : SlashCommand { override val name = "dev" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { if (!GlobalVal.devUserIds.contains(event.interaction.user.id)) { return Responder.followupEphemeral(event, getMessage("error.notDeveloper", settings)).then() } @@ -33,7 +33,7 @@ class DevCommand : SlashCommand { } } - private fun patronSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun patronSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("guild").flatMap { it.value }) .map(ApplicationCommandInteractionOptionValue::asString) .map(Snowflake::of) @@ -49,7 +49,7 @@ class DevCommand : SlashCommand { .then() } - private fun devSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun devSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("guild").flatMap { it.value }) .map(ApplicationCommandInteractionOptionValue::asString) .map(Snowflake::of) @@ -65,7 +65,7 @@ class DevCommand : SlashCommand { .then() } - private fun maxCalSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun maxCalSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("guild").flatMap { it.value }) .map(ApplicationCommandInteractionOptionValue::asString) .map(Snowflake::of) @@ -84,7 +84,7 @@ class DevCommand : SlashCommand { }.then() } - private fun apiRegisterSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun apiRegisterSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("user").flatMap { it.value }) .flatMap(ApplicationCommandInteractionOptionValue::asUser) .flatMap { user -> @@ -109,7 +109,7 @@ class DevCommand : SlashCommand { .then() } - private fun apiBlockSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun apiBlockSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("key").flatMap { it.value }) .map(ApplicationCommandInteractionOptionValue::asString) .flatMap(DatabaseManager::getAPIAccount) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DiscalCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DiscalCommand.kt index 64b48456..c5674437 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DiscalCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/DiscalCommand.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.commands -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.DiscalEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -12,7 +12,7 @@ class DiscalCommand : SlashCommand { override val name = "discal" override val ephemeral = false - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return event.interaction.guild .flatMap(DiscalEmbed::info) .flatMap { Responder.followup(event, it) } diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/EventsCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/EventsCommand.kt index 4426d1dc..c0c01354 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/EventsCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/EventsCommand.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.commands -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.EventEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -21,7 +21,7 @@ class EventsCommand : SlashCommand { override val name = "events" override val ephemeral = false - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return when (event.options[0].name) { "upcoming" -> upcomingEventsSubcommand(event, settings) "ongoing" -> ongoingEventsSubcommand(event, settings) @@ -31,7 +31,7 @@ class EventsCommand : SlashCommand { } } - private fun upcomingEventsSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun upcomingEventsSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { //Determine which calendar they want to use... val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } @@ -71,7 +71,7 @@ class EventsCommand : SlashCommand { }).then() } - private fun ongoingEventsSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun ongoingEventsSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1).flatMap { calNum -> @@ -104,7 +104,7 @@ class EventsCommand : SlashCommand { }.then() } - private fun eventsTodaySubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun eventsTodaySubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1).flatMap { calNum -> @@ -137,7 +137,7 @@ class EventsCommand : SlashCommand { }.then() } - private fun eventsRangeSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun eventsRangeSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val gMono = event.interaction.guild.cache() val calMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/HelpCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/HelpCommand.kt index 642a7f81..6cb88757 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/HelpCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/HelpCommand.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.commands -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.core.`object`.BotSettings import org.dreamexposure.discal.core.`object`.GuildSettings @@ -12,7 +12,7 @@ class HelpCommand : SlashCommand { override val name = "help" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Responder.followupEphemeral( event, getMessage("error.workInProgress", settings, "${BotSettings.BASE_URL.get()}/commands") diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/LinkCalendarCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/LinkCalendarCommand.kt index 1c2bb78c..6e745b9a 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/LinkCalendarCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/LinkCalendarCommand.kt @@ -1,7 +1,7 @@ package org.dreamexposure.discal.client.commands import discord4j.core.`object`.command.ApplicationCommandInteractionOptionValue -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.CalendarEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -14,7 +14,7 @@ class LinkCalendarCommand : SlashCommand { override val name = "linkcal" override val ephemeral = false - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.getOption("number")) .flatMap { Mono.justOrEmpty(it.value) } .map(ApplicationCommandInteractionOptionValue::asLong) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/RsvpCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/RsvpCommand.kt index eb082934..050e07c4 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/RsvpCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/RsvpCommand.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.commands -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.RsvpEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -17,7 +17,7 @@ class RsvpCommand : SlashCommand { override val name = "rsvp" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return when (event.options[0].name) { "ontime" -> onTime(event, settings) "late" -> late(event, settings) @@ -31,7 +31,7 @@ class RsvpCommand : SlashCommand { } } - private fun onTime(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun onTime(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -65,7 +65,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun late(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun late(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -99,7 +99,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun unsure(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun unsure(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -129,7 +129,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun notGoing(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun notGoing(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -159,7 +159,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun remove(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun remove(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -188,7 +188,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun list(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun list(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val calNumMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -207,7 +207,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun limit(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun limit(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val cMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) @@ -247,7 +247,7 @@ class RsvpCommand : SlashCommand { }).then() } - private fun role(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun role(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { val cMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value }) .map { it.asLong().toInt() } .defaultIfEmpty(1) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SettingsCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SettingsCommand.kt index 2a65008c..d732b043 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SettingsCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SettingsCommand.kt @@ -1,7 +1,7 @@ package org.dreamexposure.discal.client.commands import discord4j.core.`object`.command.ApplicationCommandInteractionOptionValue -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.SettingsEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -18,7 +18,7 @@ class SettingsCommand : SlashCommand { override val name = "settings" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { //Check if user has permission to use this return event.interaction.member.get().hasElevatedPermissions().flatMap { hasPerm -> if (hasPerm) { @@ -37,14 +37,14 @@ class SettingsCommand : SlashCommand { } } - private fun viewSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun viewSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return event.interaction.guild .flatMap { SettingsEmbed.getView(it, settings) } .flatMap { Responder.followup(event, it) } .then() } - private fun roleSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun roleSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("role")) .map { it.value.get() } .flatMap(ApplicationCommandInteractionOptionValue::asRole) @@ -55,7 +55,7 @@ class SettingsCommand : SlashCommand { }.then() } - private fun announcementStyleSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun announcementStyleSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("style")) .map { it.value.get() } .map { AnnouncementStyle.fromValue(it.asLong().toInt()) } @@ -69,7 +69,7 @@ class SettingsCommand : SlashCommand { }.then() } - private fun languageSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun languageSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("lang")) .map { it.value.get() } .map(ApplicationCommandInteractionOptionValue::asString) @@ -79,7 +79,7 @@ class SettingsCommand : SlashCommand { .then() } - private fun timeFormatSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun timeFormatSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.options[0].getOption("format")) .map { it.value.get() } .map { TimeFormat.fromValue(it.asLong().toInt()) } @@ -90,7 +90,7 @@ class SettingsCommand : SlashCommand { }.then() } - private fun brandingSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono { + private fun brandingSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return if (settings.patronGuild) { Mono.justOrEmpty(event.options[0].getOption("use")) .map { it.value.get() } diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SlashCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SlashCommand.kt index 91082993..87fd0a42 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SlashCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/SlashCommand.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.commands -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.core.`object`.GuildSettings import org.dreamexposure.discal.core.utils.MessageSourceLoader import reactor.core.publisher.Mono @@ -10,7 +10,7 @@ interface SlashCommand { val ephemeral: Boolean - fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono + fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono fun getMessage(key: String, settings: GuildSettings, vararg args: String): String { val src = MessageSourceLoader.getSourceByPath("command/$name/$name") diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/TimeCommand.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/TimeCommand.kt index b99f651c..0645e2b2 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/commands/TimeCommand.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/commands/TimeCommand.kt @@ -1,7 +1,7 @@ package org.dreamexposure.discal.client.commands import discord4j.core.`object`.command.ApplicationCommandInteractionOptionValue -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.message.Responder import org.dreamexposure.discal.client.message.embed.CalendarEmbed import org.dreamexposure.discal.core.`object`.GuildSettings @@ -14,7 +14,7 @@ class TimeCommand : SlashCommand { override val name = "time" override val ephemeral = true - override fun handle(event: SlashCommandEvent, settings: GuildSettings): Mono { + override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono { return Mono.justOrEmpty(event.getOption("number")) .flatMap { Mono.justOrEmpty(it.value) } .map(ApplicationCommandInteractionOptionValue::asLong) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/listeners/discord/SlashCommandListener.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/listeners/discord/SlashCommandListener.kt index 4bde12d7..de1d3ba4 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/listeners/discord/SlashCommandListener.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/listeners/discord/SlashCommandListener.kt @@ -1,6 +1,6 @@ package org.dreamexposure.discal.client.listeners.discord -import discord4j.core.event.domain.interaction.SlashCommandEvent +import discord4j.core.event.domain.interaction.ChatInputInteractionEvent import org.dreamexposure.discal.client.commands.SlashCommand import org.dreamexposure.discal.core.database.DatabaseManager import org.dreamexposure.discal.core.logger.LOGGER @@ -11,7 +11,7 @@ import reactor.core.publisher.Mono class SlashCommandListener(applicationContext: ApplicationContext) { private val cmds = applicationContext.getBeansOfType(SlashCommand::class.java).values - fun handle(event: SlashCommandEvent): Mono { + fun handle(event: ChatInputInteractionEvent): Mono { if (!event.interaction.guildId.isPresent) { return event.reply("Commands not supported in DMs.") } diff --git a/server/src/main/kotlin/org/dreamexposure/discal/server/network/discord/GlobalCommandRegistrar.kt b/server/src/main/kotlin/org/dreamexposure/discal/server/network/discord/GlobalCommandRegistrar.kt index 88bca84e..06ca2914 100644 --- a/server/src/main/kotlin/org/dreamexposure/discal/server/network/discord/GlobalCommandRegistrar.kt +++ b/server/src/main/kotlin/org/dreamexposure/discal/server/network/discord/GlobalCommandRegistrar.kt @@ -62,8 +62,13 @@ class GlobalCommandRegistrar( } private fun hasChanged(discordCommand: ApplicationCommandData, command: ApplicationCommandRequest): Boolean { + //Check type + val dCommandType = discordCommand.type().toOptional().orElse(1) + val commandType = command.type().toOptional().orElse(1) + if (dCommandType != commandType) return true + //Check description - if (!discordCommand.description().equals(command.description())) return true + if (!discordCommand.description().equals(command.description().toOptional().orElse(""))) return true //Check default perm val dCommandPerm = discordCommand.defaultPermission().toOptional().orElse(true)