Compare commits
No commits in common. "cc17eb0bd9050a3ba8d5b97e267ce1449535501a" and "0a8d526ff12142dfd83ae3e7231b9cda126bd968" have entirely different histories.
cc17eb0bd9
...
0a8d526ff1
|
@ -41,8 +41,6 @@ public class Main extends ListenerAdapter
|
||||||
private final Searcher searcher;
|
private final Searcher searcher;
|
||||||
private JDA jda;
|
private JDA jda;
|
||||||
|
|
||||||
private VoiceChannel currentVoiceChannel = null;
|
|
||||||
|
|
||||||
private List<Result> lastSearchResults;
|
private List<Result> lastSearchResults;
|
||||||
|
|
||||||
private int trackNumber = 1;
|
private int trackNumber = 1;
|
||||||
|
@ -129,8 +127,6 @@ public class Main extends ListenerAdapter
|
||||||
|
|
||||||
if (content.startsWith("!join "))
|
if (content.startsWith("!join "))
|
||||||
onJoinCommand(event, guild, arg);
|
onJoinCommand(event, guild, arg);
|
||||||
else if (content.equals("!leave"))
|
|
||||||
onLeaveCommand(event);
|
|
||||||
else if (content.equals("!join"))
|
else if (content.equals("!join"))
|
||||||
onJoinCommand(event);
|
onJoinCommand(event);
|
||||||
else if (content.startsWith("!play "))
|
else if (content.startsWith("!play "))
|
||||||
|
@ -205,15 +201,6 @@ public class Main extends ListenerAdapter
|
||||||
onConnecting(channel, textChannel); // Let the user know, we were successful!
|
onConnecting(channel, textChannel); // Let the user know, we were successful!
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onLeaveCommand(GuildMessageReceivedEvent event)
|
|
||||||
{
|
|
||||||
if (currentVoiceChannel != null)
|
|
||||||
{
|
|
||||||
disconnect();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onPlayCommand(GuildMessageReceivedEvent event, Guild guild, String arg)
|
private void onPlayCommand(GuildMessageReceivedEvent event, Guild guild, String arg)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -397,9 +384,7 @@ public class Main extends ListenerAdapter
|
||||||
{
|
{
|
||||||
String help = "Commands available:\n"
|
String help = "Commands available:\n"
|
||||||
+ "!join <Channel> - Joins a voice channel\n"
|
+ "!join <Channel> - Joins a voice channel\n"
|
||||||
+ "!leave - Leaves the current voice channel\n"
|
|
||||||
+ "!play <URL> - Downloads the track at that URL and adds it to the queue.\n"
|
+ "!play <URL> - Downloads the track at that URL and adds it to the queue.\n"
|
||||||
+ "!play <Search> - Searches for a track and displays a selection menu.\n"
|
|
||||||
+ "!queue - Show the songs currently playing and the current queue.\n"
|
+ "!queue - Show the songs currently playing and the current queue.\n"
|
||||||
+ "!remove <Index> - Remove the song at position <Index> from the queue.\n"
|
+ "!remove <Index> - Remove the song at position <Index> from the queue.\n"
|
||||||
+ "!skip - Skip the current song and play the next one.\n"
|
+ "!skip - Skip the current song and play the next one.\n"
|
||||||
|
@ -457,20 +442,6 @@ public class Main extends ListenerAdapter
|
||||||
// audioManager.setReceivingHandler(handler);
|
// audioManager.setReceivingHandler(handler);
|
||||||
// Connect to the voice channel
|
// Connect to the voice channel
|
||||||
audioManager.openAudioConnection(channel);
|
audioManager.openAudioConnection(channel);
|
||||||
currentVoiceChannel = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void disconnect()
|
|
||||||
{
|
|
||||||
if (currentVoiceChannel != null)
|
|
||||||
{
|
|
||||||
Guild guild = currentVoiceChannel.getGuild();
|
|
||||||
AudioManager audioManager = guild.getAudioManager();
|
|
||||||
audioManager.setSendingHandler(null);
|
|
||||||
audioManager.closeAudioConnection();
|
|
||||||
musicHandler = null;
|
|
||||||
currentVoiceChannel = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,7 @@ public class MusicHandler implements AudioSendHandler, Closeable, Consumer<Song>
|
||||||
}
|
}
|
||||||
if (currentSong != null)
|
if (currentSong != null)
|
||||||
{
|
{
|
||||||
if (!currentSong.isKept())
|
currentSong.delete();
|
||||||
currentSong.delete();
|
|
||||||
currentSong = null;
|
currentSong = null;
|
||||||
}
|
}
|
||||||
currentSong = songQueue.poll();
|
currentSong = songQueue.poll();
|
||||||
|
|
|
@ -22,7 +22,6 @@ public class Song
|
||||||
|
|
||||||
private String requestedBy;
|
private String requestedBy;
|
||||||
private String requestedIn;
|
private String requestedIn;
|
||||||
private boolean kept = false;
|
|
||||||
|
|
||||||
public Song(URL url)
|
public Song(URL url)
|
||||||
{
|
{
|
||||||
|
@ -101,16 +100,6 @@ public class Song
|
||||||
this.requestedIn = requestedIn;
|
this.requestedIn = requestedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isKept()
|
|
||||||
{
|
|
||||||
return kept;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKept(boolean kept)
|
|
||||||
{
|
|
||||||
this.kept = kept;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue