Quelques changements.
La commande record fonctionne maintenant
This commit is contained in:
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
9
.idea/JdrBot.iml
generated
Normal file
9
.idea/JdrBot.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?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>
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="11" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/gradle.xml
generated
Normal file
17
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
25
.idea/jarRepositories.xml
generated
Normal file
25
.idea/jarRepositories.xml
generated
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="MavenRepo" />
|
||||||
|
<option name="name" value="MavenRepo" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="BintrayJCenter" />
|
||||||
|
<option name="name" value="BintrayJCenter" />
|
||||||
|
<option name="url" value="https://jcenter.bintray.com/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
65
.idea/libraries-with-intellij-classes.xml
generated
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="libraries-with-intellij-classes">
|
||||||
|
<option name="intellijApiContainingLibraries">
|
||||||
|
<list>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIU" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIU" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIC" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.idea" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="ideaIC" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPY" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPY" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPC" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.pycharm" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="pycharmPC" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="clion" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.clion" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="clion" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="riderRD" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.rider" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="riderRD" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="goland" />
|
||||||
|
<option name="groupId" value="com.jetbrains.intellij.goland" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
<LibraryCoordinatesState>
|
||||||
|
<option name="artifactId" value="goland" />
|
||||||
|
<option name="groupId" value="com.jetbrains" />
|
||||||
|
</LibraryCoordinatesState>
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?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>
|
||||||
2
.idea/modules/JdrBot.iml
generated
Normal file
2
.idea/modules/JdrBot.iml
generated
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module external.linked.project.id="JdrBot" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" type="JAVA_MODULE" version="4" />
|
||||||
6
.idea/thriftCompiler.xml
generated
Normal file
6
.idea/thriftCompiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ThriftCompiler">
|
||||||
|
<compilers />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -7,15 +7,19 @@ import javax.security.auth.login.LoginException;
|
|||||||
|
|
||||||
import fr.Skydust.JdrBot.cmds.*;
|
import fr.Skydust.JdrBot.cmds.*;
|
||||||
import fr.Skydust.JdrBot.cmds.playmusic.*;
|
import fr.Skydust.JdrBot.cmds.playmusic.*;
|
||||||
|
import fr.Skydust.JdrBot.cmds.record.CancelRecord;
|
||||||
|
import fr.Skydust.JdrBot.cmds.record.Record;
|
||||||
|
import fr.Skydust.JdrBot.cmds.record.StopRecord;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.JDA;
|
import net.dv8tion.jda.api.JDA;
|
||||||
import net.dv8tion.jda.api.JDABuilder;
|
import net.dv8tion.jda.api.JDABuilder;
|
||||||
import net.dv8tion.jda.api.entities.Activity;
|
import net.dv8tion.jda.api.entities.Activity;
|
||||||
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||||
|
|
||||||
public class JdrBot {
|
public class JdrBot {
|
||||||
public static String Version = "2.4";
|
public static String Version = "2.6";
|
||||||
|
|
||||||
static JDA jda;
|
public static JDA jda;
|
||||||
public static LocalDateTime basedate;
|
public static LocalDateTime basedate;
|
||||||
public static List<Command> commandList;
|
public static List<Command> commandList;
|
||||||
|
|
||||||
@@ -24,17 +28,18 @@ public class JdrBot {
|
|||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
try {
|
try {
|
||||||
basedate = LocalDateTime.now();
|
basedate = LocalDateTime.now();
|
||||||
jda = JDABuilder.createDefault("MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM").build();
|
jda = JDABuilder.createDefault("MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM")
|
||||||
|
.setActivity(Activity.playing("un jeu de rôle"))
|
||||||
|
.enableCache(CacheFlag.VOICE_STATE).build();
|
||||||
jda.awaitReady();
|
jda.awaitReady();
|
||||||
jda.getPresence().setActivity(Activity.playing("un jeu de rôle"));
|
|
||||||
|
|
||||||
commandList = new ArrayList<Command>();
|
commandList = new ArrayList<Command>();
|
||||||
|
|
||||||
registerCommand(new Aide());
|
registerCommand(new Aide());
|
||||||
registerCommand(new Etat());
|
registerCommand(new Etat());
|
||||||
registerCommand(new Roll());
|
registerCommand(new Roll());
|
||||||
//registerCommand(new Record());
|
registerCommand(new Record());
|
||||||
//registerCommand(new StopRecord());
|
registerCommand(new StopRecord());
|
||||||
|
registerCommand(new CancelRecord());
|
||||||
registerCommand(new Emote());
|
registerCommand(new Emote());
|
||||||
registerCommand(new PlayMusic());
|
registerCommand(new PlayMusic());
|
||||||
registerCommand(new StopMusic());
|
registerCommand(new StopMusic());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import fr.Skydust.JdrBot.cmds.LastTimeOnline;
|
import fr.Skydust.JdrBot.cmds.LastTimeOnline;
|
||||||
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||||
|
import fr.Skydust.JdrBot.cmds.playmusic.StopMusic;
|
||||||
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
||||||
@@ -19,8 +20,6 @@ public class JdrBotListener extends ListenerAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
||||||
System.out.println(e.getMessage().getAuthor().getName() + ": " + e.getMessage().getContentRaw());
|
|
||||||
|
|
||||||
// IF it doesn't start with the startcmdchar, ignore for optimization
|
// IF it doesn't start with the startcmdchar, ignore for optimization
|
||||||
if (!e.getMessage().getContentRaw().matches("^("+ JdrBot.startcmdchar+").*$") || e.getMessage().getAuthor().isBot())
|
if (!e.getMessage().getContentRaw().matches("^("+ JdrBot.startcmdchar+").*$") || e.getMessage().getAuthor().isBot())
|
||||||
return;
|
return;
|
||||||
@@ -45,16 +44,16 @@ public class JdrBotListener extends ListenerAdapter {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
public void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
||||||
PlayMusic.onGuildVoiceMove(e);
|
StopMusic.onGuildVoiceMove(e);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
||||||
PlayMusic.onGuildVoiceLeave(e);
|
StopMusic.onGuildVoiceLeave(e);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onMessageReactionAdd(MessageReactionAddEvent e) { JukeboxGUISystem.onMessageReactionAdd(e); }
|
public void onMessageReactionAdd(MessageReactionAddEvent e) { JukeboxGUISystem.onMessageReactionAdd(e); }
|
||||||
|
|
||||||
public boolean isACommand(String message, String cmd) {
|
public boolean isACommand(String message, String cmd) {
|
||||||
return message.matches("^("+ JdrBot.startcmdchar+")("+cmd+").*$");
|
return message.matches("^("+ JdrBot.startcmdchar +")("+ cmd +")( .*|)$");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
package fr.Skydust.JdrBot.audio.handler;
|
package fr.Skydust.JdrBot.audio.handler;
|
||||||
|
|
||||||
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayer;
|
||||||
|
import com.sedmelluq.discord.lavaplayer.track.playback.AudioFrame;
|
||||||
import fr.Skydust.JdrBot.cmds.record.Record;
|
import fr.Skydust.JdrBot.cmds.record.Record;
|
||||||
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import net.dv8tion.jda.api.audio.AudioReceiveHandler;
|
import net.dv8tion.jda.api.audio.AudioReceiveHandler;
|
||||||
import net.dv8tion.jda.api.audio.CombinedAudio;
|
import net.dv8tion.jda.api.audio.CombinedAudio;
|
||||||
import net.dv8tion.jda.api.audio.UserAudio;
|
import net.dv8tion.jda.api.audio.UserAudio;
|
||||||
|
|
||||||
public class JdrBotARH implements AudioReceiveHandler {
|
public class JdrBotARH implements AudioReceiveHandler {
|
||||||
|
private final RecordState recordState;
|
||||||
|
|
||||||
String guild;
|
String guild;
|
||||||
public JdrBotARH(String guild) {
|
public JdrBotARH(RecordState rs) {
|
||||||
this.guild = guild;
|
this.recordState = rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -23,8 +28,8 @@ public class JdrBotARH implements AudioReceiveHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleCombinedAudio(CombinedAudio arg0) {
|
public void handleCombinedAudio(CombinedAudio arg0) {
|
||||||
if(Record.rbs.get(guild) != null) {
|
if(recordState.isRecording) {
|
||||||
Record.rbs.get(guild).addBytes(arg0.getAudioData(1.0));
|
recordState.addBytes(arg0.getAudioData(1.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,12 @@ public class Aide extends Command {
|
|||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i< JdrBot.commandList.size(); i++)
|
for (int i = 0; i < JdrBot.commandList.size(); i++)
|
||||||
{
|
{
|
||||||
Command cmd = JdrBot.commandList.get(i);
|
Command cmd = JdrBot.commandList.get(i);
|
||||||
sb.append("`"+cmd.cmdName+"` - *"+cmd.cmdDesc+"*"+ ((i != JdrBot.commandList.size()-1) ? "\n" : ""));
|
if(!cmd.hidden) {
|
||||||
|
sb.append("`"+cmd.cmdName + ((cmd.cmdUsage.equals("")) ? "" : " "+cmd.cmdUsage) +"` - *"+cmd.cmdDesc+"*"+ ((i != JdrBot.commandList.size()-1) ? "\n" : ""));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.getChannel().sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder()
|
e.getChannel().sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder()
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ public class LastTimeOnline extends Command {
|
|||||||
|
|
||||||
public LastTimeOnline() {
|
public LastTimeOnline() {
|
||||||
SetName("lasttimeonline|lto");
|
SetName("lasttimeonline|lto");
|
||||||
SetDesc("Dis depuis combien de temps un utilisateur est en ligne/hors-ligne");
|
SetDesc("Dit depuis combien de temps un utilisateur est en ligne/hors-ligne");
|
||||||
|
SetUsage("[Mention]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ public class Roll extends Command {
|
|||||||
|
|
||||||
public Roll() {
|
public Roll() {
|
||||||
SetName("r|roll");
|
SetName("r|roll");
|
||||||
SetDesc("Lance un dé (USAGE:roll [NombreDés]d[NombreFaces] OU roll [NombreFaces]");
|
SetDesc("Lance un dé");
|
||||||
|
SetUsage("[NombreDés]d[NombreFaces] OU [NombreFaces]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -10,15 +12,23 @@ public class FLoad extends Command {
|
|||||||
public FLoad() {
|
public FLoad() {
|
||||||
SetName("fload");
|
SetName("fload");
|
||||||
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
||||||
|
SetUsage("[URL/Recherche]");
|
||||||
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length)," ");
|
if(e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel() != null) {
|
||||||
|
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length), " ");
|
||||||
|
|
||||||
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
||||||
//ytsearch:query
|
//ytsearch:query
|
||||||
|
|
||||||
PlayMusic.loadAndPlay(e.getChannel(), args, false, false);
|
PlayMusic.loadAndPlay(e.getChannel(), args, false, false);
|
||||||
|
|
||||||
|
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Forçage du lancement de "+args);
|
||||||
|
} else {
|
||||||
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes dans un salon vocal");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
@@ -10,17 +12,23 @@ public class FLoadLoop extends Command {
|
|||||||
public FLoadLoop() {
|
public FLoadLoop() {
|
||||||
SetName("floadloop");
|
SetName("floadloop");
|
||||||
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
||||||
|
SetUsage("[URL/Recherche]");
|
||||||
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length)," ");
|
if(e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel() != null) {
|
||||||
|
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length)," ");
|
||||||
|
|
||||||
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
||||||
|
|
||||||
if(!args.matches(".*(https?)://.*")) {
|
if(!args.matches(".*(https?)://.*")) {
|
||||||
args = "ytsearch:"+args;
|
args = "ytsearch:"+args;
|
||||||
|
}
|
||||||
|
PlayMusic.loadAndPlay(e.getChannel(), StringUtils.join(args," "), true, false);
|
||||||
|
} else {
|
||||||
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes dans un salon vocal");
|
||||||
}
|
}
|
||||||
PlayMusic.loadAndPlay(e.getChannel(), StringUtils.join(args," "), true, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,38 +58,6 @@ public class PlayMusic extends Command {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
|
||||||
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getName().equals(e.getGuild().getAudioManager().getConnectedChannel().getName()) && e.getChannelLeft().getMembers().size() == 1) {
|
|
||||||
JukeboxGUI gui = JukeboxGUISystem.getGuildsJukebox(e.getGuild());
|
|
||||||
if(gui != null) {
|
|
||||||
e.getGuild().getTextChannelById(gui.TextChannelID).deleteMessageById(gui.MessageID)
|
|
||||||
.queue(msg -> {
|
|
||||||
JukeboxGUISystem.setGuildsJukebox(e.getGuild(), null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getGuildAudioPlayer(e.getGuild()).scheduler.stop();
|
|
||||||
if(Record.rbs.get(e.getGuild().getId()) == null) {
|
|
||||||
e.getGuild().getAudioManager().closeAudioConnection();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
|
||||||
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getName().equals(e.getGuild().getAudioManager().getConnectedChannel().getName()) && e.getChannelLeft().getMembers().size() == 1) {
|
|
||||||
JukeboxGUI gui = JukeboxGUISystem.getGuildsJukebox(e.getGuild());
|
|
||||||
if(gui != null) {
|
|
||||||
e.getGuild().getTextChannelById(gui.TextChannelID).deleteMessageById(gui.MessageID)
|
|
||||||
.queue(msg -> {
|
|
||||||
JukeboxGUISystem.setGuildsJukebox(e.getGuild(), null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
getGuildAudioPlayer(e.getGuild()).scheduler.stop();
|
|
||||||
//if(Record.rbs.get(e.getGuild().getId()) == null) {
|
|
||||||
e.getGuild().getAudioManager().closeAudioConnection();
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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) {
|
||||||
System.out.println(trackUrl);
|
System.out.println(trackUrl);
|
||||||
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import fr.Skydust.JdrBot.jukebox.JukeboxGUI;
|
|||||||
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
||||||
|
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class StopMusic extends Command {
|
public class StopMusic extends Command {
|
||||||
@@ -15,21 +18,38 @@ public class StopMusic extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
if(!e.getGuild().getAudioManager().isConnected() && e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
if(!e.getGuild().getAudioManager().isConnected() || !e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JukeboxGUI gui = JukeboxGUISystem.getGuildsJukebox(e.getGuild());
|
stopMusic(e.getGuild());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
||||||
|
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getName().equals(e.getGuild().getAudioManager().getConnectedChannel().getName()) && e.getChannelLeft().getMembers().size() == 1) {
|
||||||
|
stopMusic(e.getGuild());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
||||||
|
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getName().equals(e.getGuild().getAudioManager().getConnectedChannel().getName()) && e.getChannelLeft().getMembers().size() == 1) {
|
||||||
|
stopMusic(e.getGuild());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void stopMusic(Guild g) {
|
||||||
|
JukeboxGUI gui = JukeboxGUISystem.getGuildsJukebox(g);
|
||||||
|
|
||||||
if(gui != null) {
|
if(gui != null) {
|
||||||
e.getGuild().getTextChannelById(gui.TextChannelID).deleteMessageById(gui.MessageID)
|
g.getTextChannelById(gui.TextChannelID).deleteMessageById(gui.MessageID)
|
||||||
.queue(msg -> {
|
.queue(msg -> {
|
||||||
JukeboxGUISystem.setGuildsJukebox(e.getGuild(), null);
|
JukeboxGUISystem.setGuildsJukebox(g, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
PlayMusic.getGuildAudioPlayer(e.getGuild()).scheduler.stop();
|
PlayMusic.getGuildAudioPlayer(g).scheduler.stop();
|
||||||
if(Record.rbs.get(e.getGuild().getId()) == null) {
|
|
||||||
e.getGuild().getAudioManager().closeAudioConnection();
|
if(!Record.getGuildRecordState(g).isRecording) {
|
||||||
}
|
g.getAudioManager().closeAudioConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/main/java/fr/Skydust/JdrBot/cmds/record/CancelRecord.java
Executable file
25
src/main/java/fr/Skydust/JdrBot/cmds/record/CancelRecord.java
Executable file
@@ -0,0 +1,25 @@
|
|||||||
|
package fr.Skydust.JdrBot.cmds.record;
|
||||||
|
|
||||||
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
|
public class CancelRecord extends Command {
|
||||||
|
public CancelRecord() {
|
||||||
|
SetName("crecord|cr");
|
||||||
|
SetDesc("Annule l'enregistrement");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
|
if(rs.isRecording) {
|
||||||
|
rs.cancelRecord(e.getGuild());
|
||||||
|
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "L'enregistrement a été annulé");
|
||||||
|
} else {
|
||||||
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Il n'y a aucun enregistrement en cours");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,36 +3,57 @@ package fr.Skydust.JdrBot.cmds.record;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import fr.Skydust.JdrBot.audio.GuildMusicManager;
|
||||||
import fr.Skydust.JdrBot.audio.handler.JdrBotARH;
|
import fr.Skydust.JdrBot.audio.handler.JdrBotARH;
|
||||||
import fr.Skydust.JdrBot.stock.RecordState;
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class Record extends Command {
|
public class Record extends Command {
|
||||||
public static HashMap<String, RecordState> rbs = new HashMap<String, RecordState>();
|
public static HashMap<Long, RecordState> recordStates = new HashMap<>();
|
||||||
|
|
||||||
public Record() {
|
public Record() {
|
||||||
SetName("record");
|
SetName("record");
|
||||||
SetDesc("Enregistre le chat vocal");
|
SetDesc("Enregistre le chat vocal");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e)
|
public void call(GuildMessageReceivedEvent e)
|
||||||
{
|
{
|
||||||
if(rbs.get(e.getGuild().getId()) == null) {
|
RecordState currentRS = getGuildRecordState(e.getGuild());
|
||||||
rbs.put(e.getGuild().getId(), new RecordState());
|
|
||||||
}
|
if(e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel() != null && !currentRS.isRecording && !currentRS.isProcessing) {
|
||||||
|
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");
|
||||||
|
|
||||||
if(e.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel() != null && !rbs.get(e.getGuild().getId()).isRecording() && !rbs.get(e.getGuild().getId()).isProcessing()) {
|
|
||||||
if(rbs.get(e.getGuild().getId()).isProcessing()) {
|
|
||||||
e.getChannel().sendMessage(e.getAuthor().getAsMention()+" Un enregistrement est en train d'etre sauvegarde envoye");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
e.getChannel().sendMessage(e.getAuthor().getAsMention()+" Lancement du record").queue();
|
|
||||||
System.out.println("["+new Date().toString()+"] 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.getGuild().getMember(e.getAuthor()).getVoiceState().getChannel());
|
||||||
rbs.get(e.getGuild().getId()).setRecording(true);e.getGuild().getAudioManager().setReceivingHandler(new JdrBotARH(e.getGuild().getId()));
|
|
||||||
|
currentRS.newRecord();
|
||||||
|
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 {
|
||||||
e.getChannel().sendMessage(e.getAuthor().getAsMention()+" n'est pas dans la channel vocal et ou a deja demarre un enregistrement!");
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes pas dans un salon vocal");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static synchronized RecordState getGuildRecordState(Guild guild) {
|
||||||
|
long guildId = Long.parseLong(guild.getId());
|
||||||
|
RecordState recordState = recordStates.get(guildId);
|
||||||
|
|
||||||
|
if (recordState == null) {
|
||||||
|
recordState = new RecordState();
|
||||||
|
recordStates.put(guildId, recordState);
|
||||||
|
|
||||||
|
guild.getAudioManager().setReceivingHandler(new JdrBotARH(recordState));
|
||||||
|
}
|
||||||
|
|
||||||
|
return recordState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
package fr.Skydust.JdrBot.cmds.record;
|
package fr.Skydust.JdrBot.cmds.record;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
|
|
||||||
public class StopRecord extends Command {
|
public class StopRecord extends Command {
|
||||||
@@ -11,11 +14,11 @@ public class StopRecord extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(GuildMessageReceivedEvent e) {
|
||||||
if(Record.rbs.get(e.getGuild().getId()) != null && Record.rbs.get(e.getGuild().getId()).isRecording()) {
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
Record.rbs.get(e.getGuild().getId()).endRecord(e.getGuild(), e.getChannel());
|
if(rs.isRecording) {
|
||||||
Record.rbs.put(e.getGuild().getId(), null);
|
rs.endRecord(e.getGuild(), e.getChannel());
|
||||||
} else {
|
} else {
|
||||||
e.getChannel().sendMessage("PERSONNE N'ENREGISTRE <3").queue();
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Il n'y a aucun enregistrement en cours");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,15 @@ import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
|||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
public String cmdName;
|
public String cmdName;
|
||||||
public String cmdDesc;
|
public String cmdDesc;
|
||||||
|
public String cmdUsage = "";
|
||||||
|
public boolean hidden = false;
|
||||||
|
|
||||||
public abstract void call(GuildMessageReceivedEvent e);
|
public abstract void call(GuildMessageReceivedEvent e);
|
||||||
|
|
||||||
|
public void Hide() {
|
||||||
|
hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void SetName(String name) {
|
public void SetName(String name) {
|
||||||
this.cmdName = name;
|
this.cmdName = name;
|
||||||
}
|
}
|
||||||
@@ -15,4 +21,8 @@ public abstract class Command {
|
|||||||
public void SetDesc(String desc) {
|
public void SetDesc(String desc) {
|
||||||
this.cmdDesc = desc;
|
this.cmdDesc = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetUsage(String usage) {
|
||||||
|
this.cmdUsage = usage;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,8 @@ import java.util.List;
|
|||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
||||||
import fr.Skydust.JdrBot.utils.ByteArrayOutputStreamT;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.lingala.zip4j.ZipFile;
|
import net.lingala.zip4j.ZipFile;
|
||||||
@@ -22,95 +23,94 @@ import ws.schild.jave.Encoder;
|
|||||||
import ws.schild.jave.EncodingAttributes;
|
import ws.schild.jave.EncodingAttributes;
|
||||||
import ws.schild.jave.MultimediaObject;
|
import ws.schild.jave.MultimediaObject;
|
||||||
|
|
||||||
|
import javax.sound.sampled.AudioFileFormat;
|
||||||
|
import javax.sound.sampled.AudioFormat;
|
||||||
|
import javax.sound.sampled.AudioInputStream;
|
||||||
|
import javax.sound.sampled.AudioSystem;
|
||||||
|
|
||||||
public class RecordState {
|
public class RecordState {
|
||||||
private boolean isRecording;
|
private static final int RECORDER_SAMPLERATE = 44100;
|
||||||
private final ByteArrayOutputStreamT bytes;
|
public boolean isRecording;
|
||||||
private boolean isProcessing;
|
private ByteArrayOutputStream recordData;
|
||||||
|
public boolean isProcessing;
|
||||||
public RecordState() {
|
|
||||||
isRecording = false;
|
|
||||||
isProcessing = false;
|
|
||||||
bytes = new ByteArrayOutputStreamT();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRecording(boolean Record) {
|
|
||||||
isRecording = Record;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRecording() {
|
|
||||||
return isRecording;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProcessing(boolean Process) {
|
|
||||||
isProcessing = Process;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isProcessing() {
|
|
||||||
return isProcessing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addBytes(byte[] bytes) {
|
public void addBytes(byte[] bytes) {
|
||||||
if(!isProcessing && isRecording) {
|
try {
|
||||||
try {
|
this.recordData.write(bytes);
|
||||||
this.bytes.write(bytes);
|
} catch (IOException e) {
|
||||||
} catch (IOException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ByteArrayOutputStreamT getBytes() {
|
public ByteArrayOutputStream getRecordData() {
|
||||||
return bytes;
|
return recordData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void newRecord() {
|
||||||
|
recordData = new ByteArrayOutputStream();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelRecord(Guild g) {
|
||||||
|
isRecording = false;
|
||||||
|
|
||||||
|
// Called from cancelRecord that checks if "isRecording" so it can't be processing
|
||||||
|
try {
|
||||||
|
if (recordData != null) {
|
||||||
|
recordData.close();
|
||||||
|
recordData = null;
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(JukeboxGUISystem.getGuildsJukebox(g) == null) {
|
||||||
|
g.getAudioManager().closeAudioConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endRecord(Guild g, TextChannel tc) {
|
public void endRecord(Guild g, TextChannel tc) {
|
||||||
setRecording(false);
|
isRecording = false;
|
||||||
setProcessing(true);
|
isProcessing = true;
|
||||||
|
|
||||||
if(JukeboxGUISystem.getGuildsJukebox(g) == null) {
|
if(JukeboxGUISystem.getGuildsJukebox(g) == null) {
|
||||||
g.getAudioManager().closeAudioConnection();
|
g.getAudioManager().closeAudioConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("["+new Date().toString()+"] 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");
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
recordFinish(tc);
|
processRecording(tc);
|
||||||
setProcessing(false);
|
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
tc.sendMessage("["+new Date().toString()+"] Une erreur est survenue pendant l'enregistrement sur le serveur ID "+g.getId()+"("+g.getName()+")").queue();
|
System.out.println("["+new Date()+"] Une erreur est survenue pendant l'enregistrement sur le serveur ID "+g.getId()+"("+g.getName()+")");
|
||||||
|
|
||||||
|
Utils.sendMessage(tc, MessageType.ERROR, "Une erreur est survenue pendant l'enregistrement.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
bytes.close();
|
recordData.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
setProcessing(false);
|
|
||||||
}
|
}
|
||||||
|
isProcessing = false;
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recordFinish(TextChannel tc) throws ZipException, IOException, IllegalArgumentException, EncoderException, ws.schild.jave.EncoderException {
|
public void processRecording(TextChannel tc) throws IOException, IllegalArgumentException, EncoderException, ws.schild.jave.EncoderException {
|
||||||
//Bytes to Wav
|
//BigEndian, 16 bit signed, 44100hz
|
||||||
|
|
||||||
|
|
||||||
FileOutputStream out = new FileOutputStream("test.pcm");
|
|
||||||
out.write(bytes.toByteArray());
|
|
||||||
out.close();
|
|
||||||
|
|
||||||
|
|
||||||
String OriginalName = new Date().toString().replaceAll(":", "-");
|
String OriginalName = new Date().toString().replaceAll(":", "-");
|
||||||
|
|
||||||
File wavFile = new File(OriginalName+".wav");
|
File wavFile = new File(OriginalName+".wav");
|
||||||
File mp3File = new File(OriginalName+".mp3");
|
File mp3File = new File(OriginalName+".mp3");
|
||||||
|
|
||||||
//AudioSystem.write(ais, AudioFileFormat.Type.WAVE, wavFile);
|
//PCM to Wave
|
||||||
//rawToWave(bytes.toByteArray(), wavFile);
|
rawToWave(recordData, wavFile);
|
||||||
|
|
||||||
//bais.close();
|
recordData.close();
|
||||||
bytes.close();
|
recordData = null;
|
||||||
|
|
||||||
//ais.close();
|
//Wave to MP3
|
||||||
|
|
||||||
//Wav to MP3
|
|
||||||
Encoder encoder = new Encoder();
|
Encoder encoder = new Encoder();
|
||||||
AudioAttributes audio = new AudioAttributes();
|
AudioAttributes audio = new AudioAttributes();
|
||||||
audio.setCodec("libmp3lame");
|
audio.setCodec("libmp3lame");
|
||||||
@@ -121,7 +121,7 @@ public class RecordState {
|
|||||||
ea.setFormat("mp3");
|
ea.setFormat("mp3");
|
||||||
|
|
||||||
encoder.encode(new MultimediaObject(wavFile),mp3File,ea);
|
encoder.encode(new MultimediaObject(wavFile),mp3File,ea);
|
||||||
//wavFile.delete();
|
wavFile.delete();
|
||||||
|
|
||||||
//MP3 to Zip
|
//MP3 to Zip
|
||||||
ZipParameters parameters = new ZipParameters();
|
ZipParameters parameters = new ZipParameters();
|
||||||
@@ -130,11 +130,11 @@ public class RecordState {
|
|||||||
ZipFile zipFile;
|
ZipFile zipFile;
|
||||||
zipFile = new ZipFile(OriginalName+".zip");
|
zipFile = new ZipFile(OriginalName+".zip");
|
||||||
|
|
||||||
//List filesToAdd = new ArrayList<File>();
|
List<File> filesToAdd = new ArrayList<File>();
|
||||||
//filesToAdd.add(mp3File);
|
filesToAdd.add(mp3File);
|
||||||
|
|
||||||
//zipFile.createSplitZipFile(filesToAdd, parameters, true, 8283750);
|
zipFile.createSplitZipFile(filesToAdd, parameters, true, 8283750);
|
||||||
//mp3File.delete();
|
mp3File.delete();
|
||||||
|
|
||||||
//Send Files through Discord
|
//Send Files through Discord
|
||||||
if(zipFile.getSplitZipFiles().size() > 1) {
|
if(zipFile.getSplitZipFiles().size() > 1) {
|
||||||
@@ -150,5 +150,26 @@ public class RecordState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines a default audio format used to record
|
||||||
|
*/
|
||||||
|
private AudioFormat getAudioFormat() {
|
||||||
|
float sampleRate = 44100;
|
||||||
|
int sampleSizeInBits = 16;
|
||||||
|
int channels = 2;
|
||||||
|
boolean signed = true;
|
||||||
|
boolean bigEndian = true;
|
||||||
|
return new AudioFormat(sampleRate, sampleSizeInBits, channels, signed, bigEndian);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void rawToWave(ByteArrayOutputStream input, File wavFile) throws IOException {
|
||||||
|
AudioFormat format = getAudioFormat();
|
||||||
|
byte[] audioData = input.toByteArray();
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(audioData);
|
||||||
|
AudioInputStream audioInputStream = new AudioInputStream(bais, format, audioData.length / format.getFrameSize());
|
||||||
|
|
||||||
|
AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, wavFile);
|
||||||
|
|
||||||
|
audioInputStream.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
package fr.Skydust.JdrBot.utils;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
|
|
||||||
public class ByteArrayOutputStreamT extends ByteArrayOutputStream {
|
|
||||||
@Override
|
|
||||||
public byte toByteArray()[] {
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
6
src/main/java/fr/Skydust/JdrBot/utils/MessageType.java
Normal file
6
src/main/java/fr/Skydust/JdrBot/utils/MessageType.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package fr.Skydust.JdrBot.utils;
|
||||||
|
|
||||||
|
public enum MessageType {
|
||||||
|
ERROR,
|
||||||
|
NORMAL
|
||||||
|
}
|
||||||
@@ -1,5 +1,14 @@
|
|||||||
package fr.Skydust.JdrBot.utils;
|
package fr.Skydust.JdrBot.utils;
|
||||||
|
|
||||||
|
import fr.Skydust.JdrBot.JdrBot;
|
||||||
|
import fr.Skydust.JdrBot.cmds.record.Record;
|
||||||
|
import fr.Skydust.JdrBot.jukebox.JukeboxGUISystem;
|
||||||
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
@@ -34,4 +43,27 @@ public class Utils {
|
|||||||
}
|
}
|
||||||
return String.format("%d heures", (absSeconds /3600));
|
return String.format("%d heures", (absSeconds /3600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendMessage(TextChannel channel, MessageType msgType, String message) {
|
||||||
|
Color c = Color.GREEN;
|
||||||
|
String title = "Message";
|
||||||
|
|
||||||
|
if(msgType == MessageType.ERROR) {
|
||||||
|
c = Color.RED;
|
||||||
|
title = "Erreur";
|
||||||
|
}
|
||||||
|
|
||||||
|
channel.sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder().
|
||||||
|
setDescription(message)
|
||||||
|
.setTitle(title, null)
|
||||||
|
.setFooter("", JdrBot.jda.getSelfUser().getAvatarUrl())
|
||||||
|
.setColor(c)
|
||||||
|
.build()).build()).queue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void closeAudioConnection(Guild guild) {
|
||||||
|
if(JukeboxGUISystem.getGuildsJukebox(guild) == null && !Record.getGuildRecordState(guild).isRecording) {
|
||||||
|
guild.getAudioManager().closeAudioConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user