Skip to content

Commit 9135ee6

Browse files
committed
Fix lyrics command
1 parent a81da55 commit 9135ee6

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

bot/src/main/kotlin/me/duncte123/skybot/commands/music/LyricsCommand.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ import me.duncte123.skybot.objects.command.CommandContext
3030
import me.duncte123.skybot.objects.command.MusicCommand
3131
import me.duncte123.skybot.utils.chunkForEmbed
3232
import net.dv8tion.jda.api.EmbedBuilder
33+
import net.dv8tion.jda.api.entities.MessageEmbed
3334
import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
3435
import net.dv8tion.jda.api.interactions.commands.OptionType
3536
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData
3637
import kotlin.jvm.optionals.getOrNull
38+
import kotlin.math.min
3739

3840
class LyricsCommand : MusicCommand() {
3941
init {
@@ -180,6 +182,7 @@ class LyricsCommand : MusicCommand() {
180182
cb(buildLyricsEmbed(info))
181183
}
182184
}) {
185+
it.printStackTrace()
183186
cb(null)
184187
}
185188
}
@@ -189,11 +192,16 @@ class LyricsCommand : MusicCommand() {
189192
.setTitle("Lyrics for ${data.title}", data.url)
190193
.setThumbnail(data.artUrl)
191194

192-
data.lyrics.chunkForEmbed(450).forEachIndexed { index, chunk ->
195+
val lyrics = data.lyrics
196+
val trimmedLyrics = lyrics.substring(
197+
0 until min(lyrics.length, 5800) // seems like a good max length
198+
)
199+
200+
trimmedLyrics.chunkForEmbed(450).forEachIndexed { index, chunk ->
193201
builder.addField("**[${index + 1}]**", chunk, true)
194202
}
195203

196-
builder.setFooter("Lyrics provided by ${data.source}")
204+
builder.setFooter("Source: ${data.source}")
197205

198206
return builder
199207
}

0 commit comments

Comments
 (0)