Correction de 2-3 ptits trucs

This commit is contained in:
2021-05-08 05:22:01 +02:00
parent 11f92f4542
commit 6eb2bdea91
5 changed files with 8 additions and 18 deletions

View File

@@ -55,7 +55,6 @@ public class PlayMusic extends Command {
} else { } else {
JukeboxGUISystem.createJukebox(e.getChannel()); JukeboxGUISystem.createJukebox(e.getChannel());
} }
} }
public static void loadAndPlay(final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) { public static void loadAndPlay(final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
@@ -67,7 +66,6 @@ public class PlayMusic extends Command {
if(!nomsg) { if(!nomsg) {
channel.sendMessage("**Now Playing**: "+track.getInfo().title).queue(); channel.sendMessage("**Now Playing**: "+track.getInfo().title).queue();
} }
System.out.println("Launching track pre:"+track.getInfo().title);
musicManager.scheduler.play(track, loop); musicManager.scheduler.play(track, loop);
} }
@@ -82,7 +80,6 @@ public class PlayMusic extends Command {
if(!nomsg) { if(!nomsg) {
channel.sendMessage("**Now Playing**: "+firstTrack.getInfo().title).queue(); channel.sendMessage("**Now Playing**: "+firstTrack.getInfo().title).queue();
} }
System.out.println("Launching track pre:"+firstTrack.getInfo().title);
musicManager.scheduler.play(firstTrack, loop); musicManager.scheduler.play(firstTrack, loop);
} }
@@ -110,5 +107,4 @@ public class PlayMusic extends Command {
return musicManager; return musicManager;
} }
} }

View File

@@ -1,5 +1,6 @@
package fr.Skydust.JdrBot.cmds.record; package fr.Skydust.JdrBot.cmds.record;
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
import fr.Skydust.JdrBot.stock.Command; import fr.Skydust.JdrBot.stock.Command;
import fr.Skydust.JdrBot.stock.RecordState; import fr.Skydust.JdrBot.stock.RecordState;
import fr.Skydust.JdrBot.utils.MessageType; import fr.Skydust.JdrBot.utils.MessageType;
@@ -16,6 +17,9 @@ public class CancelRecord extends Command {
public void call(GuildMessageReceivedEvent e) { public void call(GuildMessageReceivedEvent e) {
RecordState rs = Record.getGuildRecordState(e.getGuild()); RecordState rs = Record.getGuildRecordState(e.getGuild());
if(rs.isRecording) { if(rs.isRecording) {
if(JukeboxGUISystem.getGuildsJukebox(e.getGuild()) == null) {
e.getGuild().getAudioManager().closeAudioConnection();
}
rs.cancelRecord(e.getGuild()); rs.cancelRecord(e.getGuild());
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "L'enregistrement a été annulé"); Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "L'enregistrement a été annulé");
} else { } else {

View File

@@ -1,5 +1,6 @@
package fr.Skydust.JdrBot.cmds.record; package fr.Skydust.JdrBot.cmds.record;
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
import fr.Skydust.JdrBot.stock.Command; import fr.Skydust.JdrBot.stock.Command;
import fr.Skydust.JdrBot.stock.RecordState; import fr.Skydust.JdrBot.stock.RecordState;
import fr.Skydust.JdrBot.utils.MessageType; import fr.Skydust.JdrBot.utils.MessageType;
@@ -16,6 +17,9 @@ public class StopRecord extends Command {
public void call(GuildMessageReceivedEvent e) { public void call(GuildMessageReceivedEvent e) {
RecordState rs = Record.getGuildRecordState(e.getGuild()); RecordState rs = Record.getGuildRecordState(e.getGuild());
if(rs.isRecording) { if(rs.isRecording) {
if(JukeboxGUISystem.getGuildsJukebox(e.getGuild()) == null) {
e.getGuild().getAudioManager().closeAudioConnection();
}
rs.endRecord(e.getGuild(), e.getChannel()); rs.endRecord(e.getGuild(), e.getChannel());
} else { } else {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Il n'y a aucun enregistrement en cours"); Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Il n'y a aucun enregistrement en cours");

View File

@@ -62,19 +62,11 @@ public class RecordState {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(JukeboxGUISystem.getGuildsJukebox(g) == null) {
g.getAudioManager().closeAudioConnection();
}
} }
public void endRecord(Guild g, TextChannel tc) { public void endRecord(Guild g, TextChannel tc) {
isRecording = false; isRecording = false;
isProcessing = true; isProcessing = true;
if(JukeboxGUISystem.getGuildsJukebox(g) == null) {
g.getAudioManager().closeAudioConnection();
}
System.out.println("["+new Date()+"] Le serveur ID "+g.getId()+"("+g.getName()+") vient de terminer un enregistrement"); System.out.println("["+new Date()+"] Le serveur ID "+g.getId()+"("+g.getName()+") vient de terminer un enregistrement");

View File

@@ -60,10 +60,4 @@ public class Utils {
.setColor(c) .setColor(c)
.build()).build()).queue(); .build()).build()).queue();
} }
public static void closeAudioConnection(Guild guild) {
if(JukeboxGUISystem.getGuildsJukebox(guild) == null && !Record.getGuildRecordState(guild).isRecording) {
guild.getAudioManager().closeAudioConnection();
}
}
} }