mirror of
https://github.com/DreamExposure/DisCal-Discord-Bot.git
synced 2026-01-23 12:29:31 -06:00
Update to latest D4J snapshot
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
//TODO: Remove dev-only and switch to patron-only once this is completed
|
||||
return if (settings.devGuild) {
|
||||
Mono.justOrEmpty(event.interaction.member)
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun patronSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun devSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun maxCalSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun apiRegisterSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun apiBlockSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return Mono.justOrEmpty(event.options[0].getOption("key").flatMap { it.value })
|
||||
.map(ApplicationCommandInteractionOptionValue::asString)
|
||||
.flatMap(DatabaseManager::getAPIAccount)
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return event.interaction.guild
|
||||
.flatMap(DiscalEmbed::info)
|
||||
.flatMap { Responder.followup(event, it) }
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun upcomingEventsSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
//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<Void> {
|
||||
private fun ongoingEventsSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun eventsTodaySubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun eventsRangeSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
val gMono = event.interaction.guild.cache()
|
||||
|
||||
val calMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value })
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return Responder.followupEphemeral(
|
||||
event,
|
||||
getMessage("error.workInProgress", settings, "${BotSettings.BASE_URL.get()}/commands")
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return Mono.justOrEmpty(event.getOption("number"))
|
||||
.flatMap { Mono.justOrEmpty(it.value) }
|
||||
.map(ApplicationCommandInteractionOptionValue::asLong)
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun onTime(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun late(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun unsure(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun notGoing(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun remove(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun list(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun limit(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun role(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
val cMono = Mono.justOrEmpty(event.options[0].getOption("calendar").flatMap { it.value })
|
||||
.map { it.asLong().toInt() }
|
||||
.defaultIfEmpty(1)
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
//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<Void> {
|
||||
private fun viewSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return event.interaction.guild
|
||||
.flatMap { SettingsEmbed.getView(it, settings) }
|
||||
.flatMap { Responder.followup(event, it) }
|
||||
.then()
|
||||
}
|
||||
|
||||
private fun roleSubcommand(event: SlashCommandEvent, settings: GuildSettings): Mono<Void> {
|
||||
private fun roleSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun announcementStyleSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun languageSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun timeFormatSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
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<Void> {
|
||||
private fun brandingSubcommand(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return if (settings.patronGuild) {
|
||||
Mono.justOrEmpty(event.options[0].getOption("use"))
|
||||
.map { it.value.get() }
|
||||
|
||||
@@ -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<Void>
|
||||
fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void>
|
||||
|
||||
fun getMessage(key: String, settings: GuildSettings, vararg args: String): String {
|
||||
val src = MessageSourceLoader.getSourceByPath("command/$name/$name")
|
||||
|
||||
@@ -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<Void> {
|
||||
override fun handle(event: ChatInputInteractionEvent, settings: GuildSettings): Mono<Void> {
|
||||
return Mono.justOrEmpty(event.getOption("number"))
|
||||
.flatMap { Mono.justOrEmpty(it.value) }
|
||||
.map(ApplicationCommandInteractionOptionValue::asLong)
|
||||
|
||||
@@ -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<Void> {
|
||||
fun handle(event: ChatInputInteractionEvent): Mono<Void> {
|
||||
if (!event.interaction.guildId.isPresent) {
|
||||
return event.reply("Commands not supported in DMs.")
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user