fix: changed back to old defer method
Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
parent
9f5d34c74a
commit
bf44095346
10 changed files with 39 additions and 52 deletions
|
@ -35,8 +35,6 @@ import dev.kord.rest.builder.interaction.integer
|
|||
import dev.kord.rest.builder.interaction.string
|
||||
import dev.schlaubi.lavakord.LavaKord
|
||||
import dev.schlaubi.lavakord.kord.lavakord
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
object Bot {
|
||||
//The kord object gets set at app launch
|
||||
|
@ -62,40 +60,38 @@ object Bot {
|
|||
|
||||
//Register Command Listener
|
||||
kord.on<GuildChatInputCommandInteractionCreateEvent> {
|
||||
//val response = interaction.deferPublicResponse()
|
||||
coroutineScope {
|
||||
val deferred = async { interaction.deferPublicResponse() }
|
||||
val command = interaction.command
|
||||
Logger.out("Command /${command.rootName} with ${command.options.size} Option${if (command.options.size == 1) "" else "s"}")
|
||||
for (c in SlashCommandManager.commands) {
|
||||
if (c.name != command.rootName)
|
||||
continue
|
||||
val opt = mutableMapOf<CommandOption, String>()
|
||||
if (c.options != null) {
|
||||
for (o in c.options) {
|
||||
when (o.type) {
|
||||
OptionType.INT ->
|
||||
if (command.integers[o.name] != null)
|
||||
opt[o] = command.integers[o.name].toString()
|
||||
val deferred = interaction.deferPublicResponse()
|
||||
//val deferred = async { interaction.deferPublicResponse() }
|
||||
val command = interaction.command
|
||||
Logger.out("Command /${command.rootName} with ${command.options.size} Option${if (command.options.size == 1) "" else "s"}")
|
||||
for (c in SlashCommandManager.commands) {
|
||||
if (c.name != command.rootName)
|
||||
continue
|
||||
val opt = mutableMapOf<CommandOption, String>()
|
||||
if (c.options != null) {
|
||||
for (o in c.options) {
|
||||
when (o.type) {
|
||||
OptionType.INT ->
|
||||
if (command.integers[o.name] != null)
|
||||
opt[o] = command.integers[o.name].toString()
|
||||
|
||||
OptionType.STRING ->
|
||||
if (command.strings[o.name] != null)
|
||||
opt[o] = command.strings[o.name].toString()
|
||||
OptionType.STRING ->
|
||||
if (command.strings[o.name] != null)
|
||||
opt[o] = command.strings[o.name].toString()
|
||||
|
||||
OptionType.BOOLEAN ->
|
||||
if (command.booleans[o.name] != null)
|
||||
opt[o] = command.booleans[o.name].toString()
|
||||
}
|
||||
OptionType.BOOLEAN ->
|
||||
if (command.booleans[o.name] != null)
|
||||
opt[o] = command.booleans[o.name].toString()
|
||||
}
|
||||
}
|
||||
c.onSlashCommand(interaction, deferred, opt)
|
||||
return@coroutineScope
|
||||
}
|
||||
MessageUtil.sendEmbedForInteraction(
|
||||
interaction, deferred, "Command not found", "Could not find the command, which you just ran.\n" +
|
||||
"This is 110%ly an error. Please report it to limited_dev#7441."
|
||||
)
|
||||
c.onSlashCommand(interaction, deferred, opt)
|
||||
return@on
|
||||
}
|
||||
MessageUtil.sendEmbedForInteraction(
|
||||
interaction, deferred, "Command not found", "Could not find the command, which you just ran.\n" +
|
||||
"This is 110%ly an error. Please report it to limited_dev#7441."
|
||||
)
|
||||
}
|
||||
|
||||
//Register Slash Commands at Discord
|
||||
|
|
|
@ -22,13 +22,12 @@ package de.limited_dev.botendo.commands.slash.component
|
|||
import de.limited_dev.botendo.commands.slash.component.options.CommandOption
|
||||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
abstract class SlashCommand(val name: String, val description: String, val options: List<CommandOption>? = null) {
|
||||
|
||||
open suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -28,12 +28,11 @@ import de.limited_dev.botendo.util.UrlUtil
|
|||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.schlaubi.lavakord.audio.Link
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class NowPlayingCommand : SlashCommand("nowplaying", "Show what's currently playing", null) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
val guildId = interaction.guildId
|
||||
|
|
|
@ -28,7 +28,6 @@ import de.limited_dev.botendo.util.MessageUtil
|
|||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.schlaubi.lavakord.audio.Link
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class PlayCommand : SlashCommand(
|
||||
"play",
|
||||
|
@ -37,7 +36,7 @@ class PlayCommand : SlashCommand(
|
|||
) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
val guildId = interaction.guildId
|
||||
|
|
|
@ -28,12 +28,11 @@ import de.limited_dev.botendo.util.TimeUtil
|
|||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.schlaubi.lavakord.audio.Link
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class QueueCommand : SlashCommand("queue", "Show whats up next", null) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
val guildId = interaction.guildId
|
||||
|
|
|
@ -29,12 +29,11 @@ import de.limited_dev.botendo.util.UrlUtil
|
|||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.schlaubi.lavakord.audio.Link
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
val guildId = interaction.guildId
|
||||
|
|
|
@ -27,12 +27,11 @@ import de.limited_dev.botendo.util.MessageUtil
|
|||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.schlaubi.lavakord.audio.Link
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class StopCommand : SlashCommand("stop", "Stop playing and start leavin'", null) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
val guildId = interaction.guildId
|
||||
|
|
|
@ -30,7 +30,6 @@ import dev.schlaubi.lavakord.audio.Link
|
|||
import dev.schlaubi.lavakord.audio.player.Player
|
||||
import dev.schlaubi.lavakord.rest.TrackResponse
|
||||
import dev.schlaubi.lavakord.rest.loadItem
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
object MusicManager {
|
||||
private var musicManagerMap: MutableMap<Snowflake, GuildTrackScheduler> = mutableMapOf()
|
||||
|
@ -44,7 +43,7 @@ object MusicManager {
|
|||
|
||||
suspend fun addToQueue(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
link: Link,
|
||||
search: String
|
||||
) {
|
||||
|
@ -53,7 +52,7 @@ object MusicManager {
|
|||
|
||||
suspend fun addToQueue(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
link: Link,
|
||||
search: String,
|
||||
silent: Boolean
|
||||
|
|
|
@ -25,12 +25,11 @@ import de.limited_dev.botendo.commands.slash.component.options.CommandOption
|
|||
import de.limited_dev.botendo.util.MessageUtil
|
||||
import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteractionResponseBehavior
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import kotlinx.coroutines.Deferred
|
||||
|
||||
class InfoCommand : SlashCommand("info", "Shows infos about the bot", null) {
|
||||
override suspend fun onSlashCommand(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
args: Map<CommandOption, String>
|
||||
) {
|
||||
MessageUtil.sendEmbedForInteraction(interaction, deferred, "Botendo v5", "ver." + BuildConstants.version)
|
||||
|
|
|
@ -23,7 +23,6 @@ import dev.kord.core.behavior.interaction.response.DeferredPublicMessageInteract
|
|||
import dev.kord.core.behavior.interaction.response.respond
|
||||
import dev.kord.core.entity.interaction.GuildChatInputCommandInteraction
|
||||
import dev.kord.rest.builder.message.EmbedBuilder
|
||||
import kotlinx.coroutines.Deferred
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
|
@ -32,11 +31,11 @@ object MessageUtil {
|
|||
|
||||
suspend fun sendEmbedForInteraction(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
title: String,
|
||||
description: String
|
||||
) {
|
||||
deferred.await().respond {
|
||||
deferred.respond {
|
||||
embeds = mutableListOf(
|
||||
getEmbed(
|
||||
title,
|
||||
|
@ -49,12 +48,12 @@ object MessageUtil {
|
|||
|
||||
suspend fun sendEmbedForInteractionWithImage(
|
||||
interaction: GuildChatInputCommandInteraction,
|
||||
deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
|
||||
deferred: DeferredPublicMessageInteractionResponseBehavior,
|
||||
title: String,
|
||||
description: String,
|
||||
thumbnailUrl: String
|
||||
) {
|
||||
deferred.await().respond {
|
||||
deferred.respond {
|
||||
embeds = mutableListOf(
|
||||
getEmbedWithImage(
|
||||
title,
|
||||
|
|
Loading…
Reference in a new issue