Skip to content

Commit

Permalink
Fix weird issue with commands not being processed after exception
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Apr 9, 2024
1 parent fea6997 commit bab6322
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import me.devoxin.flight.api.context.Context
import me.devoxin.jukebot.audio.sources.caching.CachingSourceManager
import me.devoxin.jukebot.extensions.embed
import me.devoxin.jukebot.extensions.toTimeString
import me.devoxin.jukebot.extensions.truncate
import me.devoxin.jukebot.utils.Helpers
import me.devoxin.jukebot.utils.Limits
import me.devoxin.jukebot.utils.Scopes
Expand Down Expand Up @@ -146,7 +147,7 @@ class LoadResultHandler(
val selectMenu = StringSelectMenu.create(eventId)

for ((index, track) in tracks.withIndex()) {
selectMenu.addOption(track.info.title, index.toString(), "${track.info.author} - ${track.duration.toTimeString()}")
selectMenu.addOption(track.info.title.truncate(95), index.toString(), "${track.info.author} - ${track.duration.toTimeString()}")
}

val prompt = ctx.respond {
Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/me/devoxin/jukebot/commands/Playback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import me.devoxin.jukebot.annotations.Prerequisites.TriggerConnect
import me.devoxin.jukebot.extensions.audioPlayer
import me.devoxin.jukebot.extensions.embed
import me.devoxin.jukebot.extensions.toTimeString
import me.devoxin.jukebot.extensions.truncate
import me.devoxin.jukebot.utils.Scopes
import net.dv8tion.jda.api.events.interaction.command.CommandAutoCompleteInteractionEvent
import net.dv8tion.jda.api.interactions.commands.Command.Choice
Expand Down Expand Up @@ -137,7 +138,7 @@ class Playback : Cog {
?: return event.replyChoices().queue()

event.replyChoices(
searchResults.tracks.map { Choice("${it.info.author} - ${it.info.title} (${it.duration.toTimeString()})", it.info.uri) }
searchResults.tracks.map { Choice("${it.info.author} - ${it.info.title}".truncate(85) + " (${it.duration.toTimeString()})", it.info.uri) }
).queue()
} catch (t: Throwable) {
event.replyChoices().queue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FlightEventAdapter : DefaultCommandEventAdapter() {
ctx.embed("Incorrect Command Usage", """
$message
`${error.argument.slashFriendlyName}`': ${error.argument.description}
`${error.argument.slashFriendlyName}`: ${error.argument.description}
Syntax: `$syntax`
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/me/devoxin/jukebot/utils/Scopes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package me.devoxin.jukebot.utils

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.plus

object Scopes {
val IO = CoroutineScope(Dispatchers.IO)
val IO = CoroutineScope(Dispatchers.IO) + SupervisorJob()
}

0 comments on commit bab6322

Please sign in to comment.