Utilisation du e.getMember() au lieu de ce truc chelou que j'ai fait juste pour ce fichier

Discord record en 48000Hz et pas en 44100Hz
This commit is contained in:
2021-06-04 01:36:07 +02:00
parent 605b00026a
commit f42c58d6cd
5 changed files with 14 additions and 26 deletions

9
.idea/JdrBot.iml generated
View File

@@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated
View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/JdrBot.iml" filepath="$PROJECT_DIR$/.idea/JdrBot.iml" />
</modules>
</component>
</project>

View File

@@ -24,22 +24,27 @@ public class Record extends Command {
@Override @Override
public void call(GuildMessageReceivedEvent e) public void call(GuildMessageReceivedEvent e)
{ {
if(e.getGuild().getMember(e.getAuthor()).hasPermission(Permission.ADMINISTRATOR)) { if(e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
RecordState currentRS = getGuildRecordState(e.getGuild()); RecordState currentRS = getGuildRecordState(e.getGuild());
if (e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel() != null && !currentRS.isRecording && !currentRS.isProcessing) { if (currentRS.isProcessing) {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Un enregistrement est en cours de finalisation");
return;
}
if (currentRS.isRecording) {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Un enregistrement est déjà en cours");
return;
}
if (e.getMember().getVoiceState().getChannel() != null) {
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Lancement d'un enregistrement par " + e.getAuthor().getAsMention() + "\n`!stoprecord` pour le terminer\n`!crecord` pour annuler"); Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Lancement d'un enregistrement par " + e.getAuthor().getAsMention() + "\n`!stoprecord` pour le terminer\n`!crecord` pour annuler");
System.out.println("[" + new Date() + "] Le serveur ID " + e.getGuild().getId() + "(" + e.getGuild().getName() + ") vient de lancer un enregistrement"); System.out.println("[" + new Date() + "] Le serveur ID " + e.getGuild().getId() + "(" + e.getGuild().getName() + ") vient de lancer un enregistrement");
e.getGuild().getAudioManager().openAudioConnection(e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel()); e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
currentRS.newRecord(); currentRS.newRecord();
currentRS.isRecording = true; currentRS.isRecording = true;
} else if (currentRS.isProcessing) {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Un enregistrement est en cours de finalisation");
} else if (currentRS.isRecording) {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Un enregistrement est déjà en cours");
} else { } else {
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes pas dans un salon vocal"); Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes pas dans un salon vocal");
} }

View File

@@ -146,7 +146,7 @@ public class RecordState {
* Defines a default audio format used to record * Defines a default audio format used to record
*/ */
private AudioFormat getAudioFormat() { private AudioFormat getAudioFormat() {
float sampleRate = 44100; float sampleRate = 48000;
int sampleSizeInBits = 16; int sampleSizeInBits = 16;
int channels = 2; int channels = 2;
boolean signed = true; boolean signed = true;

View File

@@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: fr.Skydust.JdrBot.JdrBot Main-Class: fr.Skydust.JdrBot.JdrBot;