mirror of
https://github.com/JonasunderscoreJones/ZtereoMUSIC.git
synced 2025-10-25 13:39:19 +02:00
fix: clean up README and files, add comments, and add last part of previous commit that was missing
This commit is contained in:
parent
b0c00d48ee
commit
bdbf2b44d5
4 changed files with 15 additions and 15 deletions
|
|
@ -41,13 +41,6 @@
|
|||
- [ ] Proper database for server preferences (prefix etc)
|
||||
- Other TBA...
|
||||
|
||||
## Noticed problems:
|
||||
- The bot will always use the same channel (infochannel) after the first command which makes it behave strangely if you switch text chat after the first channel.
|
||||
- Uh oh a track did something strange appears sometimes... (last time was when asking for a track in another channel)
|
||||
- The bot randomly disconnects from the vc
|
||||
- Queue index starts from 0
|
||||
- Sometimes the bot stops showing the green outline (maybe client bug, very rare)
|
||||
|
||||
## Thankies
|
||||
This wouldn't have been possible without the amazing folks behind [lavaplayer](https://github.com/sedmelluq/lavaplayer) and [JDA](https://github.com/DV8FromTheWorld/JDA).
|
||||
And without ReperakDev and FoxShadew. Thank you.
|
||||
|
|
@ -2,7 +2,6 @@ package codes.ztereohype.ztereomusic.audio;
|
|||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||
//import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioSourceManager;
|
||||
import net.dv8tion.jda.api.audio.AudioSendHandler;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.sedmelluq.discord.lavaplayer.tools.FriendlyException;
|
|||
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
import com.sedmelluq.discord.lavaplayer.track.AudioTrackEndReason;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
|
||||
|
|
@ -16,8 +17,9 @@ import java.util.List;
|
|||
public class TrackManager extends AudioEventAdapter {
|
||||
private final @Getter AudioPlayer player;
|
||||
public final List<AudioTrack> trackQueue = new ArrayList<>();
|
||||
private final MessageChannel infoChannel;
|
||||
private @Getter @Setter MessageChannel infoChannel;
|
||||
private final Guild guild;
|
||||
private boolean trackHasErrored = false; // this is a temporary workaround that helps me debug stuff. will be removed.
|
||||
|
||||
public TrackManager(AudioPlayerManager playerManager, MessageChannel infoChannel, Guild guild) {
|
||||
this.player = playerManager.createPlayer();
|
||||
|
|
@ -110,9 +112,16 @@ public class TrackManager extends AudioEventAdapter {
|
|||
|
||||
@Override
|
||||
public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) {
|
||||
infoChannel.sendMessage("Uh oh, a track did something strange. Skipping...").queue();
|
||||
trackQueue.remove(track);
|
||||
playNext();
|
||||
System.out.println(exception.getMessage());
|
||||
|
||||
if (!trackHasErrored) {
|
||||
infoChannel.sendMessage("Uh oh, a track did something strange. The error was: " + exception.getMessage() + ". Trying to replay...").queue();
|
||||
player.playTrack(track);
|
||||
} else {
|
||||
infoChannel.sendMessage("The error happened again. Skipping...").queue();
|
||||
playNext();
|
||||
}
|
||||
trackHasErrored = !trackHasErrored;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -2,14 +2,11 @@ package codes.ztereohype.ztereomusic.networking;
|
|||
|
||||
import codes.ztereohype.ztereomusic.ZtereoMUSIC;
|
||||
import net.shadew.json.Json;
|
||||
import net.shadew.json.JsonNode;
|
||||
import net.shadew.json.JsonPath;
|
||||
import net.shadew.json.JsonSyntaxException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Optional;
|
||||
|
||||
public class YoutubeSearch {
|
||||
|
|
@ -27,8 +24,10 @@ public class YoutubeSearch {
|
|||
e.printStackTrace();
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
JsonPath path = JsonPath.parse("items[0].id.videoId");
|
||||
|
||||
//todo: actually check if there is a response before parsing directly to the response + get the music-related one with most views
|
||||
try {
|
||||
return Optional.ofNullable(JSON.parse(jsonResponse).query(path).asString());
|
||||
} catch (JsonSyntaxException e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue