Skip to content

Commit

Permalink
Add save_uri to tracks, might be usefull
Browse files Browse the repository at this point in the history
  • Loading branch information
duncte123 committed Nov 26, 2023
1 parent 7f035e2 commit fbfa6d3
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.dunctebot.lavalinkplugin;

import com.dunctebot.sourcemanagers.IWillUseIdentifierInstead;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import dev.arbjerg.lavalink.api.AudioPluginInfoModifier;
import kotlinx.serialization.json.JsonElementKt;
import kotlinx.serialization.json.JsonObject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class DuncteBotPluginInfoModifier implements AudioPluginInfoModifier {
@Nullable
@Override
public JsonObject modifyAudioTrackPluginInfo(@NotNull AudioTrack track) {
final String uri;

if (track instanceof IWillUseIdentifierInstead) {
uri = track.getInfo().identifier;
} else {
uri = track.getInfo().uri;
}

return new JsonObject(Map.of(
"save_uri", JsonElementKt.JsonPrimitive(uri)
));
}
}

0 comments on commit fbfa6d3

Please sign in to comment.