Added topic restoration after music player is shutdown
This commit is contained in:
1 parent
f37ad7f8d6
commit
f704468aad
2 files changed
+5
-2
No files matched your search
@@ -34,6 +34,7 @@ public class MusicManager {
|
||||
private final static Map<String, MusicManager> managers = new ConcurrentHashMap<>();
|
||||
private long guildId;
|
||||
private boolean isPlaying = false;
|
||||
private String topic;
|
||||
|
||||
private MusicManager(Guild guild) {
|
||||
|
||||
@@ -93,7 +94,7 @@ public class MusicManager {
|
||||
|
||||
public synchronized void stopMusic() {
|
||||
if (scheduler.getTextChannel() != null)
|
||||
scheduler.getTextChannel().getManager().setTopic("").queue();
|
||||
scheduler.getTextChannel().getManager().setTopic(scheduler.topic).queue();
|
||||
|
||||
player.destroy();
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public class TrackScheduler extends AudioEventAdapter {
|
||||
private final AudioPlayer player;
|
||||
private TextChannel channel;
|
||||
public final BlockingQueue<AudioTrack> queue;
|
||||
public String topic;
|
||||
|
||||
public TrackScheduler(AudioPlayer player) {
|
||||
this.player = player;
|
||||
@@ -40,6 +41,7 @@ public class TrackScheduler extends AudioEventAdapter {
|
||||
|
||||
public void setTextChannel(TextChannel channel) {
|
||||
this.channel = channel;
|
||||
topic = channel.getTopic();
|
||||
}
|
||||
|
||||
public TextChannel getTextChannel() {
|
||||
@@ -56,7 +58,7 @@ public class TrackScheduler extends AudioEventAdapter {
|
||||
if (track != null)
|
||||
channel.getManager().setTopic(":speaker: Now playing : " + track.getInfo().title).queue();
|
||||
else
|
||||
channel.getManager().setTopic("").queue();
|
||||
channel.getManager().setTopic(topic).queue();
|
||||
player.startTrack(track, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user