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