Skip to content

Commit

Permalink
Show new LavaSrc fields in song embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
DRSchlaubi committed Aug 14, 2023
1 parent 6308233 commit 7b50e5a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ kord = "0.10.0-SNAPSHOT"
jjwt = "0.11.5"
api = "3.23.5"
ksp = "1.9.0-1.0.11"
lavakord = "5.1.6"
lavakord = "feature-new-lavasrc-fields-SNAPSHOT"

[libraries]
kord-common = { group = "dev.kord", name = "kord-common", version.ref = "kord" }
Expand Down
2 changes: 1 addition & 1 deletion music/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
subprojects {
version = "3.1.3-SNAPSHOT"
version = "3.1.4-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.arbjerg.lavalink.protocol.v4.Track
import dev.kord.common.Color
import dev.kord.rest.builder.message.EmbedBuilder
import dev.nycode.imagecolor.ImageColorClient
import dev.schlaubi.lavakord.plugins.lavasrc.lavaSrcInfo
import dev.schlaubi.mikbot.plugin.api.util.Translator
import dev.schlaubi.mikmusic.core.Config
import kotlin.time.DurationUnit
Expand Down Expand Up @@ -51,6 +52,7 @@ suspend fun EmbedBuilder.addSong(translate: Translator, track: Track) {
}

val video = track.findOnYoutube()
val lavaSrcInfo = runCatching { track.lavaSrcInfo }.getOrNull()
if (video != null) {
val info = video.snippet
val channel = getFirstChannelById(info.channelId).snippet
Expand All @@ -61,9 +63,14 @@ suspend fun EmbedBuilder.addSong(translate: Translator, track: Track) {
icon = channel.thumbnails.high.url
}
} else {
field {
name = translate("music.track.author", "music")
value = track.info.author
author {
name = track.info.title
if (lavaSrcInfo != null) {
if (lavaSrcInfo.artistUrl != null) {
url = lavaSrcInfo.artistUrl
}
icon = lavaSrcInfo.artistArtworkUrl
}
}
}
}

0 comments on commit 7b50e5a

Please sign in to comment.