fix: changed the defer method to hopefully fix the "app did not respond" issue

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-04-01 16:57:51 +02:00
parent 3395d53bf6
commit fc922206bb
10 changed files with 78 additions and 63 deletions

View file

@ -35,6 +35,8 @@ 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
@ -60,37 +62,41 @@ object Bot {
//Register Command Listener //Register Command Listener
kord.on<GuildChatInputCommandInteractionCreateEvent> { kord.on<GuildChatInputCommandInteractionCreateEvent> {
val response = interaction.deferPublicResponse() //val response = 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 -> coroutineScope {
if (command.strings[o.name] != null) val deferred = async { interaction.deferPublicResponse() }
opt[o] = command.strings[o.name].toString() 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.BOOLEAN -> OptionType.STRING ->
if (command.booleans[o.name] != null) if (command.strings[o.name] != null)
opt[o] = command.booleans[o.name].toString() opt[o] = command.strings[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
} }
c.onSlashCommand(interaction, response, opt) MessageUtil.sendEmbedForInteraction(
return@on 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."
)
} }
MessageUtil.sendEmbedForInteraction(
interaction, response, "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

View file

@ -22,12 +22,13 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
} }

View file

@ -28,11 +28,12 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
val guildId = interaction.guildId val guildId = interaction.guildId
@ -41,7 +42,7 @@ class NowPlayingCommand : SlashCommand("nowplaying", "Show what's currently play
if (link.state != Link.State.CONNECTED) { if (link.state != Link.State.CONNECTED) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not connected", "Not connected",
"I'm not in a VC and therefore, I am not playing anything." "I'm not in a VC and therefore, I am not playing anything."
) )
@ -51,7 +52,7 @@ class NowPlayingCommand : SlashCommand("nowplaying", "Show what's currently play
if (track == null) { if (track == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not Playing", "Not Playing",
"I'm not playing anything currently" "I'm not playing anything currently"
) )
@ -59,7 +60,7 @@ class NowPlayingCommand : SlashCommand("nowplaying", "Show what's currently play
} }
MessageUtil.sendEmbedForInteractionWithImage( MessageUtil.sendEmbedForInteractionWithImage(
interaction, interaction,
response, deferred,
"Currently playing", "Currently playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} :: ${ "**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
TimeUtil.getTimeFormatedRaw( TimeUtil.getTimeFormatedRaw(

View file

@ -28,6 +28,7 @@ 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",
@ -36,7 +37,7 @@ class PlayCommand : SlashCommand(
) { ) {
override suspend fun onSlashCommand( override suspend fun onSlashCommand(
interaction: GuildChatInputCommandInteraction, interaction: GuildChatInputCommandInteraction,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
val guildId = interaction.guildId val guildId = interaction.guildId
@ -46,7 +47,7 @@ class PlayCommand : SlashCommand(
if (voiceState == null) { if (voiceState == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not connected to a VC", "You are not connected to a VC",
"Please connect to a VC" "Please connect to a VC"
) )
@ -60,7 +61,7 @@ class PlayCommand : SlashCommand(
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) { } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not in my VC", "You are not in my VC",
"We are not in the same VC and therefore, you cannot play any music" "We are not in the same VC and therefore, you cannot play any music"
) )
@ -74,6 +75,6 @@ class PlayCommand : SlashCommand(
"ytsearch:$query" "ytsearch:$query"
} }
MusicManager.addToQueue(interaction, response, link, search) MusicManager.addToQueue(interaction, deferred, link, search)
} }
} }

View file

@ -28,11 +28,12 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
val guildId = interaction.guildId val guildId = interaction.guildId
@ -41,7 +42,7 @@ class QueueCommand : SlashCommand("queue", "Show whats up next", null) {
if (link.state != Link.State.CONNECTED) { if (link.state != Link.State.CONNECTED) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not connected", "Not connected",
"I'm not in a VC and therefore, I am not playing anything." "I'm not in a VC and therefore, I am not playing anything."
) )
@ -51,7 +52,7 @@ class QueueCommand : SlashCommand("queue", "Show whats up next", null) {
if (track == null) { if (track == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Queue empty", "Queue empty",
"I'm not playing anything currently" "I'm not playing anything currently"
) )
@ -66,6 +67,6 @@ class QueueCommand : SlashCommand("queue", "Show whats up next", null) {
continue continue
desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n" desc += tr.info.title + " - " + TimeUtil.getTimeFormatedShortend(tr.info.length) + " (" + tr.info.author + ")\n"
} }
MessageUtil.sendEmbedForInteraction(interaction, response, "Queue", desc) MessageUtil.sendEmbedForInteraction(interaction, deferred, "Queue", desc)
} }
} }

View file

@ -29,11 +29,12 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
val guildId = interaction.guildId val guildId = interaction.guildId
@ -43,7 +44,7 @@ class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null)
if (voiceState == null) { if (voiceState == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not connected to a VC", "You are not connected to a VC",
"Please connect to a VC" "Please connect to a VC"
) )
@ -54,7 +55,7 @@ class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null)
if (link.state != Link.State.CONNECTED) { if (link.state != Link.State.CONNECTED) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not connected", "Not connected",
"I'm not in a VC and therefore, I am not playing anything." "I'm not in a VC and therefore, I am not playing anything."
) )
@ -62,7 +63,7 @@ class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null)
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) { } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not in my VC", "You are not in my VC",
"We are not in the same VC and therefore, you cannot control the music" "We are not in the same VC and therefore, you cannot control the music"
) )
@ -72,7 +73,7 @@ class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null)
if (track == null) { if (track == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not playing", "Not playing",
"I'm not playing anything currently" "I'm not playing anything currently"
) )
@ -83,7 +84,7 @@ class SkipCommand : SlashCommand("skip", "Skip to the next song in queue", null)
gts.playNext() gts.playNext()
MessageUtil.sendEmbedForInteractionWithImage( MessageUtil.sendEmbedForInteractionWithImage(
interaction, interaction,
response, deferred,
"Skipped song; now playing", "Skipped song; now playing",
"**${track.title}**\n*Now Playing*\nby ${track.author} :: ${ "**${track.title}**\n*Now Playing*\nby ${track.author} :: ${
TimeUtil.getTimeFormatedRaw( TimeUtil.getTimeFormatedRaw(

View file

@ -27,11 +27,12 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
val guildId = interaction.guildId val guildId = interaction.guildId
@ -42,7 +43,7 @@ class StopCommand : SlashCommand("stop", "Stop playing and start leavin'", null)
if (voiceState == null) { if (voiceState == null) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not connected to a VC", "You are not connected to a VC",
"Please connect to my VC" "Please connect to my VC"
) )
@ -53,7 +54,7 @@ class StopCommand : SlashCommand("stop", "Stop playing and start leavin'", null)
if (link.state != Link.State.CONNECTED) { if (link.state != Link.State.CONNECTED) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Not connected", "Not connected",
"I'm not in a VC and therefore, I am not playing anything." "I'm not in a VC and therefore, I am not playing anything."
) )
@ -61,7 +62,7 @@ class StopCommand : SlashCommand("stop", "Stop playing and start leavin'", null)
} else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) { } else if (link.state == Link.State.CONNECTED && link.lastChannelId != channelId!!.value) {
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"You are not in my VC", "You are not in my VC",
"We are not in the same VC" "We are not in the same VC"
) )
@ -70,6 +71,6 @@ class StopCommand : SlashCommand("stop", "Stop playing and start leavin'", null)
player.stopTrack() player.stopTrack()
link.destroy() link.destroy()
MusicManager.getGuildTrackScheduler(interaction.getGuild(), player).clear() MusicManager.getGuildTrackScheduler(interaction.getGuild(), player).clear()
MessageUtil.sendEmbedForInteraction(interaction, response, "I stopped and left", "just like your girlfriend") MessageUtil.sendEmbedForInteraction(interaction, deferred, "I stopped and left", "just like your girlfriend")
} }
} }

View file

@ -30,6 +30,7 @@ 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()
@ -43,16 +44,16 @@ object MusicManager {
suspend fun addToQueue( suspend fun addToQueue(
interaction: GuildChatInputCommandInteraction, interaction: GuildChatInputCommandInteraction,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
link: Link, link: Link,
search: String search: String
) { ) {
addToQueue(interaction, response, link, search, false) addToQueue(interaction, deferred, link, search, false)
} }
suspend fun addToQueue( suspend fun addToQueue(
interaction: GuildChatInputCommandInteraction, interaction: GuildChatInputCommandInteraction,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
link: Link, link: Link,
search: String, search: String,
silent: Boolean silent: Boolean
@ -69,7 +70,7 @@ object MusicManager {
if (!silent) if (!silent)
MessageUtil.sendEmbedForInteractionWithImage( MessageUtil.sendEmbedForInteractionWithImage(
interaction, interaction,
response, deferred,
"Queuing track from link", "Queuing track from link",
"**${item.track.info.title}**\n*Queue*\nby ${item.track.info.author} :: ${ "**${item.track.info.title}**\n*Queue*\nby ${item.track.info.author} :: ${
TimeUtil.getTimeFormatedRaw( TimeUtil.getTimeFormatedRaw(
@ -89,7 +90,7 @@ object MusicManager {
if (!silent) if (!silent)
MessageUtil.sendEmbedForInteractionWithImage( MessageUtil.sendEmbedForInteractionWithImage(
interaction, interaction,
response, deferred,
"Queuing playlist from link", "Queuing playlist from link",
"**${item.tracks.first().info.title}**\n*${item.playlistInfo.name}*\nby ${item.tracks.first().info.author} :: ${ "**${item.tracks.first().info.title}**\n*${item.playlistInfo.name}*\nby ${item.tracks.first().info.author} :: ${
TimeUtil.getTimeFormatedRaw( TimeUtil.getTimeFormatedRaw(
@ -106,7 +107,7 @@ object MusicManager {
if (!silent) if (!silent)
MessageUtil.sendEmbedForInteractionWithImage( MessageUtil.sendEmbedForInteractionWithImage(
interaction, interaction,
response, deferred,
"Queuing track from query", "Queuing track from query",
"**${item.tracks.first().info.title}**\n*Queue*\nby ${item.tracks.first().info.author} :: ${ "**${item.tracks.first().info.title}**\n*Queue*\nby ${item.tracks.first().info.author} :: ${
TimeUtil.getTimeFormatedRaw( TimeUtil.getTimeFormatedRaw(
@ -120,14 +121,14 @@ object MusicManager {
TrackResponse.LoadType.NO_MATCHES -> { TrackResponse.LoadType.NO_MATCHES -> {
if (!silent) if (!silent)
MessageUtil.sendEmbedForInteraction(interaction, response, "Not found", "There were no matches.") MessageUtil.sendEmbedForInteraction(interaction, deferred, "Not found", "There were no matches.")
} }
TrackResponse.LoadType.LOAD_FAILED -> { TrackResponse.LoadType.LOAD_FAILED -> {
if (!silent) if (!silent)
MessageUtil.sendEmbedForInteraction( MessageUtil.sendEmbedForInteraction(
interaction, interaction,
response, deferred,
"Load failed", "Load failed",
"There was an error while loading." "There was an error while loading."
) )

View file

@ -25,13 +25,14 @@ 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,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
args: Map<CommandOption, String> args: Map<CommandOption, String>
) { ) {
MessageUtil.sendEmbedForInteraction(interaction, response, "Botendo v5", "ver." + BuildConstants.version) MessageUtil.sendEmbedForInteraction(interaction, deferred, "Botendo v5", "ver." + BuildConstants.version)
} }
} }

View file

@ -23,6 +23,7 @@ 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
@ -31,11 +32,11 @@ object MessageUtil {
suspend fun sendEmbedForInteraction( suspend fun sendEmbedForInteraction(
interaction: GuildChatInputCommandInteraction, interaction: GuildChatInputCommandInteraction,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
title: String, title: String,
description: String description: String
) { ) {
response.respond { deferred.await().respond {
embeds = mutableListOf( embeds = mutableListOf(
getEmbed( getEmbed(
title, title,
@ -48,12 +49,12 @@ object MessageUtil {
suspend fun sendEmbedForInteractionWithImage( suspend fun sendEmbedForInteractionWithImage(
interaction: GuildChatInputCommandInteraction, interaction: GuildChatInputCommandInteraction,
response: DeferredPublicMessageInteractionResponseBehavior, deferred: Deferred<DeferredPublicMessageInteractionResponseBehavior>,
title: String, title: String,
description: String, description: String,
thumbnailUrl: String thumbnailUrl: String
) { ) {
response.respond { deferred.await().respond {
embeds = mutableListOf( embeds = mutableListOf(
getEmbedWithImage( getEmbedWithImage(
title, title,