Updated the jdrbot to be at the same standard as potatos
This commit was merged in pull request #1.
This commit is contained in:
55
.gitea/workflows/production.yml
Normal file
55
.gitea/workflows/production.yml
Normal file
@@ -0,0 +1,55 @@
|
||||
# This defines the name of the workflow as it will appear in the "Actions" tab of the Gitea repository.
|
||||
name: Production deployment
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
SSH_SERVER: "192.168.1.37"
|
||||
DOCKER_IMAGE_NAME: "jdrbot"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repo's default branch
|
||||
uses: actions/checkout@v3
|
||||
- name: Install Docker
|
||||
run: curl -fsSL https://get.docker.com | sh
|
||||
- name: Docker build
|
||||
run: |
|
||||
echo ${{ secrets.DOCKER_TOKEN }} | docker login gitea.skydust.fr -u ${{ secrets.DOCKER_USER }} --password-stdin
|
||||
docker build . -t gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }}
|
||||
docker tag gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }} gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }}:latest
|
||||
- name: Docker push
|
||||
run: docker push gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }}:latest
|
||||
|
||||
deploy:
|
||||
name: Deploying
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
|
||||
steps:
|
||||
- name: Check out repo's default branch
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup the ssh key
|
||||
run: |
|
||||
mkdir ~/.ssh
|
||||
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/ssh_key
|
||||
ssh-keyscan -t rsa ${{ env.SSH_SERVER }} >> ~/.ssh/known_hosts
|
||||
chmod 700 -R ~/.ssh
|
||||
- name: Deploying
|
||||
run: |
|
||||
ssh -i ~/.ssh/ssh_key ${{ secrets.SSH_USER }}@${{ env.SSH_SERVER }} << EOF
|
||||
echo ${{ secrets.DOCKER_TOKEN }} | docker login gitea.skydust.fr -u ${{ secrets.DOCKER_USER }} --password-stdin
|
||||
PREVIOUS_IMAGE=\$(docker inspect ${{ env.DOCKER_IMAGE_NAME }} --format "{{.Image}}")
|
||||
docker stop ${{ env.DOCKER_IMAGE_NAME }} || true
|
||||
docker rm ${{ env.DOCKER_IMAGE_NAME }} || true
|
||||
docker image rm \${PREVIOUS_IMAGE} || true
|
||||
docker pull gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }}:latest
|
||||
docker run --restart=always -d --name="${{ env.DOCKER_IMAGE_NAME }}" gitea.skydust.fr/skydust/${{ env.DOCKER_IMAGE_NAME }}:latest
|
||||
EOF
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
# ---> Java
|
||||
.idea
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
|
||||
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
6
.idea/compiler.xml
generated
6
.idea/compiler.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="11" />
|
||||
</component>
|
||||
</project>
|
||||
17
.idea/gradle.xml
generated
17
.idea/gradle.xml
generated
@@ -1,17 +0,0 @@
|
||||
<?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>
|
||||
35
.idea/jarRepositories.xml
generated
35
.idea/jarRepositories.xml
generated
@@ -1,35 +0,0 @@
|
||||
<?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>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://m2.dv8tion.net/releases" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven2" />
|
||||
<option name="name" value="maven2" />
|
||||
<option name="url" value="https://jitpack.io" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
65
.idea/libraries-with-intellij-classes.xml
generated
65
.idea/libraries-with-intellij-classes.xml
generated
@@ -1,65 +0,0 @@
|
||||
<?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
7
.idea/misc.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?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>
|
||||
2
.idea/modules/JdrBot.iml
generated
2
.idea/modules/JdrBot.iml
generated
@@ -1,2 +0,0 @@
|
||||
<?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
6
.idea/thriftCompiler.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ThriftCompiler">
|
||||
<compilers />
|
||||
</component>
|
||||
</project>
|
||||
124
.idea/uiDesigner.xml
generated
124
.idea/uiDesigner.xml
generated
@@ -1,124 +0,0 @@
|
||||
<?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
6
.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
14
Dockerfile
Normal file
14
Dockerfile
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM openjdk:18-ea-jdk-slim-bullseye AS builder
|
||||
WORKDIR /app
|
||||
COPY . /app
|
||||
RUN ./gradlew shadowJar
|
||||
|
||||
FROM openjdk:18-ea-slim-bullseye AS runner
|
||||
LABEL authors="skydust"
|
||||
WORKDIR /app
|
||||
|
||||
COPY --from=builder /app/build/libs/JdrBot-all.jar /app/JdrBot.jar
|
||||
COPY Songs /app/Songs
|
||||
COPY start.sh /app
|
||||
|
||||
CMD ["/bin/bash","./start.sh"]
|
||||
@@ -1,3 +1,7 @@
|
||||
# JdrBot
|
||||
|
||||
Jdr botto
|
||||
Jdr botto
|
||||
|
||||
To update gradlew:
|
||||
- Find every plugins and upgrade them
|
||||
- Run `gradle wrapper --gradle-version 8.3`
|
||||
BIN
Songs/One Folder/Violin 2.mp3
Normal file
BIN
Songs/One Folder/Violin 2.mp3
Normal file
Binary file not shown.
BIN
Songs/One Folder/Violin.mp3
Normal file
BIN
Songs/One Folder/Violin.mp3
Normal file
Binary file not shown.
BIN
Songs/Two Folder/Violin.mp3
Normal file
BIN
Songs/Two Folder/Violin.mp3
Normal file
Binary file not shown.
BIN
Songs/Two Folder/Woo/Violin.mp3
Normal file
BIN
Songs/Two Folder/Woo/Violin.mp3
Normal file
Binary file not shown.
BIN
Songs/Violin 2 copie 2.mp3
Normal file
BIN
Songs/Violin 2 copie 2.mp3
Normal file
Binary file not shown.
19
build.gradle
19
build.gradle
@@ -14,32 +14,29 @@ plugins {
|
||||
id 'application'
|
||||
|
||||
// Shadow plugin to make uberJars
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.0'
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url 'https://m2.dv8tion.net/releases'
|
||||
}
|
||||
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'com.github.oshi:oshi-core:6.1.6'
|
||||
implementation 'com.github.oshi:oshi-json:3.13.6'
|
||||
implementation 'org.slf4j:slf4j-simple:2.0.0-alpha0'
|
||||
implementation 'net.lingala.zip4j:zip4j:2.10.0'
|
||||
implementation 'club.minnced:opus-java:1.1.1'
|
||||
implementation 'ws.schild:jave-all-deps:3.3.1'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'com.github.oshi:oshi-core:6.1.6'
|
||||
implementation 'com.github.oshi:oshi-json:3.13.6'
|
||||
implementation 'org.slf4j:slf4j-simple:2.0.9'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
implementation 'com.sedmelluq:lavaplayer:1.3.78'
|
||||
implementation 'com.github.DV8FromTheWorld:JDA:5.0.0-alpha.12'
|
||||
implementation 'dev.arbjerg:lavaplayer:2.0.1'
|
||||
implementation 'net.dv8tion:JDA:5.0.0-beta.13'
|
||||
implementation 'org.reflections:reflections:0.10.2'
|
||||
}
|
||||
|
||||
application {
|
||||
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
294
gradlew
vendored
294
gradlew
vendored
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env sh
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -17,67 +17,99 @@
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
##
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "`uname`" in
|
||||
CYGWIN* )
|
||||
cygwin=true
|
||||
;;
|
||||
Darwin* )
|
||||
darwin=true
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
@@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# For Darwin, add options to specify how the application appears in the dock
|
||||
if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
# We build the pattern for arguments to be converted via cygpath
|
||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
||||
SEP=""
|
||||
for dir in $ROOTDIRSRAW ; do
|
||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
||||
SEP="|"
|
||||
done
|
||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
||||
# Add a user-defined pattern to the cygpath arguments
|
||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
||||
fi
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
i=0
|
||||
for arg in "$@" ; do
|
||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||
|
||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||
else
|
||||
eval `echo args$i`="\"$arg\""
|
||||
fi
|
||||
i=`expr $i + 1`
|
||||
done
|
||||
case $i in
|
||||
0) set -- ;;
|
||||
1) set -- "$args0" ;;
|
||||
2) set -- "$args0" "$args1" ;;
|
||||
3) set -- "$args0" "$args1" "$args2" ;;
|
||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=`save "$@"`
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
|
||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
54
src/main/java/.idea/workspace.xml
generated
54
src/main/java/.idea/workspace.xml
generated
@@ -1,54 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="92be5a76-72cc-4791-b8e0-146745624e77" name="Default Changelist" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ExternalProjectsData">
|
||||
<projectState path="$PROJECT_DIR$">
|
||||
<ProjectState />
|
||||
</projectState>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../../.." />
|
||||
</component>
|
||||
<component name="ProjectId" id="1ptZSIDZd86tmu17YY146ADRTUU" />
|
||||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="settings.editor.selected.configurable" value="Errors" />
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="92be5a76-72cc-4791-b8e0-146745624e77" name="Default Changelist" comment="" />
|
||||
<created>1616004344851</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1616004344851</updated>
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,25 +1,24 @@
|
||||
package fr.Skydust.JdrBot;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import javax.security.auth.login.LoginException;
|
||||
|
||||
import fr.Skydust.JdrBot.cmds.*;
|
||||
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.utils.HeartbeatTask;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.tasks.HeartbeatTask;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
public class JdrBot {
|
||||
public static String Version = "3.1";
|
||||
public static String Version = "4.0";
|
||||
|
||||
public static JDA jda;
|
||||
public static LocalDateTime basedate;
|
||||
@@ -29,7 +28,7 @@ public class JdrBot {
|
||||
|
||||
public static boolean debugMode = false;
|
||||
|
||||
public static void main(String args[]) {
|
||||
public static void main(String[] args) {
|
||||
for (int i=0;i<args.length;i++) {
|
||||
if(args[i].equalsIgnoreCase("--heartbeat")) {
|
||||
if(i == args.length-1) { // Check for an argument after heartbeat
|
||||
@@ -61,32 +60,38 @@ public class JdrBot {
|
||||
|
||||
jda = JDABuilder.createDefault(token)
|
||||
.setActivity(Activity.playing("un jeu de rôle"))
|
||||
.enableIntents(GatewayIntent.MESSAGE_CONTENT)
|
||||
.enableCache(CacheFlag.VOICE_STATE).build();
|
||||
|
||||
jda.awaitReady();
|
||||
commandList = new ArrayList<Command>();
|
||||
|
||||
registerCommand(new Aide());
|
||||
registerCommand(new Etat());
|
||||
registerCommand(new Roll());
|
||||
registerCommand(new Record());
|
||||
registerCommand(new StopRecord());
|
||||
registerCommand(new CancelRecord());
|
||||
registerCommand(new Emote());
|
||||
registerCommand(new PlayMusic());
|
||||
registerCommand(new StopMusic());
|
||||
registerCommand(new FLoad());
|
||||
registerCommand(new FLoadLoop());
|
||||
registerCommands();
|
||||
|
||||
jda.addEventListener(new JdrBotListener());
|
||||
} catch (LoginException e) {
|
||||
System.out.println("The login token is wrong");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerCommand(Command cmd) {
|
||||
commandList.add(cmd);
|
||||
/**
|
||||
* Finds every class annotated with CommandSpec and registers them as a command.
|
||||
*/
|
||||
public static void registerCommands() {
|
||||
commandList = new ArrayList<Command>();
|
||||
|
||||
Reflections reflections = new Reflections("fr.Skydust.JdrBot.cmds");
|
||||
Set<Class<?>> annotated = reflections.getTypesAnnotatedWith(CommandSpec.class);
|
||||
|
||||
for (Class<?> command: annotated) {
|
||||
try {
|
||||
Command cmd = (Command) command.getDeclaredConstructor().newInstance();
|
||||
commandList.add(cmd);
|
||||
|
||||
System.out.println("Registered command "+ cmd.cmdName);
|
||||
} catch (InstantiationException | NoSuchMethodException | InvocationTargetException |
|
||||
IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package fr.Skydust.JdrBot;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.cmds.LastTimeOnline;
|
||||
import fr.Skydust.JdrBot.cmds.playmusic.StopMusic;
|
||||
import fr.Skydust.JdrBot.menu.MenuSystem;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.HeartbeatTask;
|
||||
import fr.Skydust.JdrBot.tasks.HeartbeatTask;
|
||||
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateOnlineStatusEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JdrBotListener extends ListenerAdapter {
|
||||
@Override
|
||||
@@ -38,24 +36,21 @@ public class JdrBotListener extends ListenerAdapter {
|
||||
|
||||
/* LastTimeOnline listener */
|
||||
@Override
|
||||
public void onUserUpdateOnlineStatus(UserUpdateOnlineStatusEvent e) {
|
||||
public void onUserUpdateOnlineStatus(@NotNull UserUpdateOnlineStatusEvent e) {
|
||||
LastTimeOnline.onUserUpdateOnlineStatus(e);
|
||||
}
|
||||
|
||||
/* Empty voice channel listener */
|
||||
@Override
|
||||
public void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
||||
StopMusic.onGuildVoiceMove(e);
|
||||
}
|
||||
@Override
|
||||
public void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
||||
StopMusic.onGuildVoiceLeave(e);
|
||||
public void onGuildVoiceUpdate(@NotNull GuildVoiceUpdateEvent e) {
|
||||
StopMusic.onGuildVoiceUpdate(e);
|
||||
}
|
||||
/* Menu system listener */
|
||||
@Override
|
||||
public void onMessageReactionAdd(MessageReactionAddEvent e) { MenuSystem.onMessageReactionAdd(e); }
|
||||
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent e) { MenuSystem.onMessageReactionAdd(e); }
|
||||
/* Heartbeat command listener */
|
||||
@Override
|
||||
public void onGatewayPing(GatewayPingEvent e) { HeartbeatTask.HeartbeatUpdateEvent(e); }
|
||||
public void onGatewayPing(@NotNull GatewayPingEvent e) { HeartbeatTask.HeartbeatUpdateEvent(e); }
|
||||
|
||||
public boolean isACommand(String message, String cmd) {
|
||||
return message.matches("^("+ JdrBot.startcmdchar +")("+ cmd +")( .*|)$");
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
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.stock.RecordState;
|
||||
import net.dv8tion.jda.api.audio.AudioReceiveHandler;
|
||||
import net.dv8tion.jda.api.audio.CombinedAudio;
|
||||
import net.dv8tion.jda.api.audio.UserAudio;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JdrBotARH implements AudioReceiveHandler {
|
||||
private final RecordState recordState;
|
||||
@@ -20,21 +18,10 @@ public class JdrBotARH implements AudioReceiveHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveUser() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleCombinedAudio(CombinedAudio arg0) {
|
||||
@Override
|
||||
public void handleCombinedAudio(@NotNull CombinedAudio combinedAudio) {
|
||||
if(recordState.isRecording) {
|
||||
recordState.addBytes(arg0.getAudioData(1.0));
|
||||
recordState.addBytes(combinedAudio.getAudioData(1.0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUserAudio(UserAudio arg0) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
33
src/main/java/fr/Skydust/JdrBot/bases/command/Command.java
Executable file
33
src/main/java/fr/Skydust/JdrBot/bases/command/Command.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package fr.Skydust.JdrBot.bases.command;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public abstract class Command {
|
||||
public String cmdName;
|
||||
public String cmdDesc;
|
||||
public String cmdUsage = "";
|
||||
public boolean hidden = false;
|
||||
|
||||
public Command() {
|
||||
if (!getClass().isAnnotationPresent(CommandSpec.class)) {
|
||||
throw new WrongCommandSpecException("The command spec was not declared ! (@CommandSpec)");
|
||||
}
|
||||
|
||||
CommandSpec specs = getClass().getAnnotation(CommandSpec.class);
|
||||
if (specs.name().isEmpty()) {
|
||||
throw new WrongCommandSpecException("The command name is invalid.");
|
||||
}
|
||||
|
||||
cmdName = specs.name();
|
||||
cmdDesc = specs.description();
|
||||
cmdUsage = specs.usage();
|
||||
|
||||
if (getClass().isAnnotationPresent(HideCommand.class)) {
|
||||
hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void call(MessageReceivedEvent e);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package fr.Skydust.JdrBot.bases.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface CommandSpec {
|
||||
String name() default "";
|
||||
|
||||
String description() default "Empty description";
|
||||
|
||||
String usage() default "";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package fr.Skydust.JdrBot.bases.command;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
public @interface HideCommand {
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package fr.Skydust.JdrBot.bases.command;
|
||||
|
||||
public class WrongCommandSpecException extends RuntimeException {
|
||||
public WrongCommandSpecException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
package fr.Skydust.JdrBot.cmds;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.bases.command.HideCommand;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@HideCommand // While its not ready
|
||||
@CommandSpec(
|
||||
name = "addsong",
|
||||
usage = "[Chemin] [URL]",
|
||||
description = "(Admin) Ajoute une musique au jukebox"
|
||||
)
|
||||
public class AddSong extends Command {
|
||||
public AddSong() {
|
||||
SetName("addsong");
|
||||
SetUsage("[Chemin] [URL]");
|
||||
SetDesc("(Admin) Ajoute une musique au jukebox");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
package fr.Skydust.JdrBot.cmds;
|
||||
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@CommandSpec(
|
||||
name = "aide",
|
||||
description = "Pour avoir de l'aide !"
|
||||
)
|
||||
public class Aide extends Command {
|
||||
public Aide() {
|
||||
SetName("aide");
|
||||
SetDesc("Pour avoir de l'aide !");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -24,11 +24,14 @@ public class Aide extends Command {
|
||||
{
|
||||
Command cmd = JdrBot.commandList.get(i);
|
||||
if(!cmd.hidden) {
|
||||
sb.append("`"+cmd.cmdName + ((cmd.cmdUsage.equals("")) ? "" : " "+cmd.cmdUsage) +"` - *"+cmd.cmdDesc+"*"+ ((i != JdrBot.commandList.size()-1) ? "\n" : ""));
|
||||
sb.append("`"+cmd.cmdName
|
||||
+ ((cmd.cmdUsage.isEmpty()) ? "" : " "+cmd.cmdUsage)
|
||||
+"` - *"+cmd.cmdDesc+"*"
|
||||
+ ((i != JdrBot.commandList.size()-1) ? "\n" : ""));
|
||||
}
|
||||
}
|
||||
|
||||
e.getChannel().sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder()
|
||||
e.getChannel().sendMessage(new MessageCreateBuilder().setEmbeds(new EmbedBuilder()
|
||||
.setDescription(sb.toString())
|
||||
.setTitle("Aide", null)
|
||||
.setFooter("Fait le " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy 'a' HH:mm:ss")), e.getJDA().getSelfUser().getAvatarUrl())
|
||||
|
||||
@@ -2,15 +2,18 @@ package fr.Skydust.JdrBot.cmds;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.bases.command.HideCommand;
|
||||
import net.dv8tion.jda.api.entities.emoji.RichCustomEmoji;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@HideCommand
|
||||
@CommandSpec(
|
||||
name = "emote",
|
||||
description = "Donne les informations techniques d'une emote"
|
||||
)
|
||||
public class Emote extends Command {
|
||||
public Emote() {
|
||||
SetName("emote");
|
||||
SetDesc("Donne les informations techniques d'une emote");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
String[] args = Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length);
|
||||
@@ -19,7 +22,7 @@ public class Emote extends Command {
|
||||
if(str.matches("<:.*:\\d+>"))
|
||||
{
|
||||
String id = str.replaceAll("<:.*:(\\d+)>", "$1");
|
||||
net.dv8tion.jda.api.entities.Emote emote = e.getJDA().getEmoteById(id);
|
||||
RichCustomEmoji emote = e.getJDA().getEmojiById(id);
|
||||
if(emote==null)
|
||||
{
|
||||
e.getChannel().sendMessage("Unknown emote:\n"
|
||||
|
||||
@@ -10,23 +10,24 @@ import java.util.Arrays;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary;
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.utils.DurationUtils;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.JDAInfo;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||
import oshi.SystemInfo;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
|
||||
@CommandSpec(
|
||||
name = "status",
|
||||
description = "Donne le status du bot et du serveur"
|
||||
)
|
||||
public class Etat extends Command {
|
||||
private static final DecimalFormat df = new DecimalFormat("###.##");
|
||||
|
||||
public Etat() {
|
||||
SetName("status");
|
||||
SetDesc("Donne le status du bot et du serveur");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
SystemInfo si = new SystemInfo();
|
||||
@@ -37,7 +38,7 @@ public class Etat extends Command {
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
Duration difference = Duration.between(JdrBot.basedate, currentDate);
|
||||
|
||||
e.getChannel().sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder()
|
||||
e.getChannel().sendMessage(new MessageCreateBuilder().setEmbeds(new EmbedBuilder()
|
||||
.setAuthor("Etat de "+ e.getGuild().getSelfMember().getEffectiveName())
|
||||
.addBlankField(false)
|
||||
.addField("CPU","-----", false)
|
||||
@@ -53,7 +54,7 @@ public class Etat extends Command {
|
||||
.addBlankField(false)
|
||||
.addField("Servers",e.getJDA().getGuilds().size()+"",true)
|
||||
.addField("Versions", "JdrBot: "+ JdrBot.Version +" - JDA: "+ JDAInfo.VERSION +" - Lavaplayer: "+ PlayerLibrary.VERSION, true)
|
||||
.addField("Uptime", Utils.formatDuration(difference), true)
|
||||
.addField("Uptime", DurationUtils.formatDuration(difference), true)
|
||||
.setFooter("*Fait le "+ currentDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy à HH:mm:ss")) +"*", e.getJDA().getSelfUser().getAvatarUrl())
|
||||
.setColor(Color.BLUE)
|
||||
.build()).build()).queue();
|
||||
|
||||
@@ -4,25 +4,25 @@ import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.utils.DurationUtils;
|
||||
import net.dv8tion.jda.api.OnlineStatus;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.user.update.UserUpdateOnlineStatusEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "lasttimeonline|lto",
|
||||
usage = "[Mention]",
|
||||
description = "Dit depuis combien de temps un utilisateur est en ligne/hors-ligne"
|
||||
)
|
||||
public class LastTimeOnline extends Command {
|
||||
static HashMap<Long, LocalDateTime> AllUsers = new HashMap<>();
|
||||
|
||||
public LastTimeOnline() {
|
||||
SetName("lasttimeonline|lto");
|
||||
SetDesc("Dit depuis combien de temps un utilisateur est en ligne/hors-ligne");
|
||||
SetUsage("[Mention]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(e.getMessage().getMentions().getUsers().size() < 1) {
|
||||
if(e.getMessage().getMentions().getUsers().isEmpty()) {
|
||||
e.getChannel().sendMessage("Vous n'avez pas mentionne d'utilisateur !").queue();
|
||||
return;
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class LastTimeOnline extends Command {
|
||||
} else {
|
||||
sb.append(u.getAsMention()+" est en ligne depuis ");
|
||||
}
|
||||
sb.append(Utils.formatDurationSmooth(Duration.between(UserDate, LocalDateTime.now())));
|
||||
sb.append(DurationUtils.formatDurationSmooth(Duration.between(UserDate, LocalDateTime.now())));
|
||||
|
||||
e.getChannel().sendMessage(sb.toString()).queue();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,19 @@ package fr.Skydust.JdrBot.cmds;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "r|roll",
|
||||
usage = "[NombreDés]d[NombreFaces] OU [NombreFaces]",
|
||||
description = "Lance un dé"
|
||||
)
|
||||
public class Roll extends Command {
|
||||
static Random r = new Random();
|
||||
|
||||
public Roll() {
|
||||
SetName("r|roll");
|
||||
SetDesc("Lance un dé");
|
||||
SetUsage("[NombreDés]d[NombreFaces] OU [NombreFaces]");
|
||||
}
|
||||
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if (e.getMessage().getContentRaw().split(" ").length != 1)
|
||||
{
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.bases.command.HideCommand;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@HideCommand
|
||||
@CommandSpec(
|
||||
name = "fload",
|
||||
description = "/!\\ Commande test /!\\ Permet de charger une musique de force",
|
||||
usage = "[URL/Recherche]"
|
||||
)
|
||||
public class FLoad extends Command {
|
||||
public FLoad() {
|
||||
SetName("fload");
|
||||
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
||||
SetUsage("[URL/Recherche]");
|
||||
Hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||
@@ -24,7 +26,7 @@ public class FLoad extends Command {
|
||||
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
||||
//ytsearch:query
|
||||
|
||||
PlayMusic.loadAndPlay(e.getGuild(), e.getChannel(), args, false, false);
|
||||
PlayMusic.loadAndPlay(e.getGuild(), (TextChannel) e.getChannel(), args, false, false);
|
||||
|
||||
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Forçage du lancement de "+args);
|
||||
} else {
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.bases.command.HideCommand;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@HideCommand
|
||||
@CommandSpec(
|
||||
name = "floadloop",
|
||||
description = "/!\\ Commande test /!\\ Permet de charger une musique de force",
|
||||
usage = "[URL/Recherche]"
|
||||
)
|
||||
public class FLoadLoop extends Command {
|
||||
public FLoadLoop() {
|
||||
SetName("floadloop");
|
||||
SetDesc("/!\\ Commande test /!\\ Permet de charger une musique de force");
|
||||
SetUsage("[URL/Recherche]");
|
||||
Hide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||
@@ -26,7 +28,7 @@ public class FLoadLoop extends Command {
|
||||
if(!args.matches(".*(https?)://.*")) {
|
||||
args = "ytsearch:"+args;
|
||||
}
|
||||
PlayMusic.loadAndPlay(e.getGuild(), e.getChannel(), StringUtils.join(args," "), true, false);
|
||||
PlayMusic.loadAndPlay(e.getGuild(), (TextChannel) e.getChannel(), StringUtils.join(args," "), true, false);
|
||||
} else {
|
||||
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes dans un salon vocal");
|
||||
}
|
||||
|
||||
@@ -3,11 +3,12 @@ package fr.Skydust.JdrBot.cmds.playmusic;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
@@ -20,6 +21,10 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
|
||||
|
||||
import fr.Skydust.JdrBot.audio.GuildMusicManager;
|
||||
|
||||
@CommandSpec(
|
||||
name = "playmusic|pm",
|
||||
description = "(Admin) Demarre le jukebox"
|
||||
)
|
||||
public class PlayMusic extends Command {
|
||||
private static final AudioPlayerManager playerManager = new DefaultAudioPlayerManager();
|
||||
static Map<Long, GuildMusicManager> musicManagers;
|
||||
@@ -27,12 +32,11 @@ public class PlayMusic extends Command {
|
||||
public static HashMap<Long, JukeboxSystem> jukeboxSystems = new HashMap<>();
|
||||
|
||||
public PlayMusic() {
|
||||
super();
|
||||
|
||||
musicManagers = new HashMap<>();
|
||||
AudioSourceManagers.registerRemoteSources(playerManager);
|
||||
AudioSourceManagers.registerLocalSource(playerManager);
|
||||
|
||||
SetName("playmusic|pm");
|
||||
SetDesc("(Admin) Demarre le jukebox");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -64,7 +68,7 @@ public class PlayMusic extends Command {
|
||||
return jukeboxSystems.get(guild.getIdLong());
|
||||
}
|
||||
|
||||
public static void loadAndPlay(final Guild guild, final MessageChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
||||
public static void loadAndPlay(final Guild guild, final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
||||
System.out.println(trackUrl);
|
||||
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer(guild);
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
package fr.Skydust.JdrBot.cmds.playmusic;
|
||||
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.cmds.record.Record;
|
||||
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
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.guild.voice.GuildVoiceUpdateEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "stopmusic|sm",
|
||||
description = "(Admin) Arrete le jukebox et supprime son message"
|
||||
)
|
||||
public class StopMusic extends Command {
|
||||
public StopMusic() {
|
||||
SetName("stopmusic|sm");
|
||||
SetDesc("(Admin) Arrete le jukebox et supprime son message");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(!e.getGuild().getAudioManager().isConnected() || !e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
@@ -24,15 +23,12 @@ public class StopMusic extends Command {
|
||||
stopMusic(e.getGuild());
|
||||
}
|
||||
|
||||
public static void onGuildVoiceLeave(GuildVoiceLeaveEvent e) {
|
||||
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getIdLong() == e.getGuild().getAudioManager().getConnectedChannel().getIdLong() && e.getChannelLeft().getMembers().size() == 1) {
|
||||
stopMusic(e.getGuild());
|
||||
}
|
||||
}
|
||||
|
||||
public static void onGuildVoiceMove(GuildVoiceMoveEvent e) {
|
||||
if(e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getIdLong() == e.getGuild().getAudioManager().getConnectedChannel().getIdLong() && e.getChannelLeft().getMembers().size() == 1) {
|
||||
stopMusic(e.getGuild());
|
||||
public static void onGuildVoiceUpdate(GuildVoiceUpdateEvent e) {
|
||||
if(e.getChannelLeft() != null) {
|
||||
if (e.getGuild().getAudioManager().isConnected() && e.getChannelLeft().getIdLong() == e.getGuild().getAudioManager().getConnectedChannel().getIdLong() && e.getChannelLeft().getMembers().size() == 1) {
|
||||
stopMusic(e.getGuild());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
package fr.Skydust.JdrBot.cmds.record;
|
||||
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.stock.RecordState;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "crecord|cr",
|
||||
description = "Annule l'enregistrement"
|
||||
)
|
||||
public class CancelRecord extends Command {
|
||||
public CancelRecord() {
|
||||
SetName("crecord|cr");
|
||||
SetDesc("Annule l'enregistrement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||
|
||||
@@ -4,22 +4,22 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import fr.Skydust.JdrBot.audio.handler.JdrBotARH;
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.stock.RecordState;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "record",
|
||||
description = "(Admin) Enregistre le chat vocal"
|
||||
)
|
||||
public class Record extends Command {
|
||||
public static HashMap<Long, RecordState> recordStates = new HashMap<>();
|
||||
|
||||
public Record() {
|
||||
SetName("record");
|
||||
SetDesc("(Admin) Enregistre le chat vocal");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package fr.Skydust.JdrBot.cmds.record;
|
||||
|
||||
import fr.Skydust.JdrBot.bases.command.Command;
|
||||
import fr.Skydust.JdrBot.bases.command.CommandSpec;
|
||||
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.stock.RecordState;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
@CommandSpec(
|
||||
name = "stoprecord|sr",
|
||||
description = "Arrete et archive l'enregistrement"
|
||||
)
|
||||
public class StopRecord extends Command {
|
||||
public StopRecord() {
|
||||
SetName("stoprecord|sr");
|
||||
SetDesc("Arrete l'enregistrement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MessageReceivedEvent e) {
|
||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||
@@ -20,7 +21,7 @@ public class StopRecord extends Command {
|
||||
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||
e.getGuild().getAudioManager().closeAudioConnection();
|
||||
}
|
||||
rs.endRecord(e.getGuild(), e.getChannel());
|
||||
rs.endRecord(e.getGuild(), (TextChannel) e.getChannel());
|
||||
} else {
|
||||
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Il n'y a aucun enregistrement en cours");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package fr.Skydust.JdrBot.utils;
|
||||
package fr.Skydust.JdrBot.enums;
|
||||
|
||||
public enum MessageType {
|
||||
ERROR,
|
||||
@@ -3,9 +3,10 @@ package fr.Skydust.JdrBot.jukebox;
|
||||
import fr.Skydust.JdrBot.cmds.playmusic.PlayMusic;
|
||||
import fr.Skydust.JdrBot.menu.Menu;
|
||||
import fr.Skydust.JdrBot.menu.MenuSystem;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import fr.Skydust.JdrBot.utils.UnicodeEmotes;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
@@ -42,7 +43,7 @@ public class JukeboxSystem {
|
||||
|
||||
// If it isn't the root folder, place the return button
|
||||
if(isntInRootFolder()) {
|
||||
items.add(Utils.ReturnUnicode + " Retour");
|
||||
items.add(UnicodeEmotes.ReturnUnicode + " Retour");
|
||||
}
|
||||
if(files != null) {
|
||||
// Sort files by alphabetical order with directories first
|
||||
@@ -59,9 +60,9 @@ public class JukeboxSystem {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if (file.isDirectory())
|
||||
sb.append(Utils.FolderUnicode);
|
||||
sb.append(UnicodeEmotes.FolderUnicode);
|
||||
else
|
||||
sb.append(Utils.SongUnicode);
|
||||
sb.append(UnicodeEmotes.SongUnicode);
|
||||
|
||||
sb.append(" ");
|
||||
sb.append(file.getName().replaceAll(".mp3", ""));
|
||||
@@ -80,7 +81,7 @@ public class JukeboxSystem {
|
||||
String str = items[itemId];
|
||||
|
||||
// Loop back to open a subfolder
|
||||
if (str.contains(Utils.FolderUnicode)) {
|
||||
if (str.contains(UnicodeEmotes.FolderUnicode)) {
|
||||
openFolder(currentFolder + "/" + getFileNameFromItem(str));
|
||||
return;
|
||||
}
|
||||
@@ -95,25 +96,29 @@ public class JukeboxSystem {
|
||||
}
|
||||
|
||||
// If not already playing
|
||||
if (str.contains(Utils.SongUnicode)) {
|
||||
if (str.contains(UnicodeEmotes.SongUnicode)) {
|
||||
if(!songPlayedPath.equals("")) {
|
||||
String folder = songPlayedPath.substring(0, songPlayedPath.lastIndexOf("/"));
|
||||
int previousSongItemID = Integer.parseInt(songPlayedPath.substring(songPlayedPath.lastIndexOf("/")+1));
|
||||
|
||||
Menu previousMenu = linkedPath.get(folder);
|
||||
previousMenu.items[previousSongItemID] = previousMenu.items[previousSongItemID].replace(Utils.PlayUnicode, Utils.SongUnicode);
|
||||
previousMenu.items[previousSongItemID] =
|
||||
previousMenu.items[previousSongItemID].replace(
|
||||
UnicodeEmotes.PlayUnicode,
|
||||
UnicodeEmotes.SongUnicode
|
||||
);
|
||||
}
|
||||
items[itemId] = items[itemId].replace(Utils.SongUnicode, Utils.PlayUnicode);
|
||||
items[itemId] = items[itemId].replace(UnicodeEmotes.SongUnicode, UnicodeEmotes.PlayUnicode);
|
||||
|
||||
String songPath = currentFolder + "/" + getFileNameFromItem(str) + ".mp3";
|
||||
|
||||
PlayMusic.loadAndPlay(msg.getGuild(), msg.getTextChannel(), songPath, true, true);
|
||||
PlayMusic.loadAndPlay(msg.getGuild(), (TextChannel) msg.getChannel(), songPath, true, true);
|
||||
|
||||
// Format: Songs/Folder/SubFolder/2
|
||||
songPlayedPath = currentFolder + "/" + itemId;
|
||||
} else {
|
||||
//If already playing, stop the song
|
||||
items[itemId] = items[itemId].replace(Utils.PlayUnicode, Utils.SongUnicode);
|
||||
items[itemId] = items[itemId].replace(UnicodeEmotes.PlayUnicode, UnicodeEmotes.SongUnicode);
|
||||
PlayMusic.getGuildAudioPlayer(member.getGuild()).scheduler.stop();
|
||||
}
|
||||
// Reload the current menu
|
||||
@@ -125,7 +130,7 @@ public class JukeboxSystem {
|
||||
|
||||
// Reget the message to update it
|
||||
Menu finalMenu = menu;
|
||||
jukeboxMessage.getTextChannel().retrieveMessageById(jukeboxMessage.getIdLong()).queue(msg -> {
|
||||
jukeboxMessage.getChannel().retrieveMessageById(jukeboxMessage.getIdLong()).queue(msg -> {
|
||||
MenuSystem.changeMenu(msg, finalMenu);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package fr.Skydust.JdrBot.menu;
|
||||
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import fr.Skydust.JdrBot.utils.UnicodeEmotes;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateData;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -25,17 +26,17 @@ public class Menu {
|
||||
public void onButtonClicked(Member member, Message msg, int itemId) { }
|
||||
|
||||
/** Builds the menu message */
|
||||
public Message makeMessage() {
|
||||
public MessageCreateData makeMessage() {
|
||||
StringBuilder str = new StringBuilder();
|
||||
|
||||
int i = 0;
|
||||
for (String s : items) {
|
||||
str.append(Utils.CharsUnicodeArray[i] +" "+ s +"\n");
|
||||
str.append(UnicodeEmotes.CharsUnicodeArray[i] +" "+ s +"\n");
|
||||
i++;
|
||||
}
|
||||
|
||||
return new MessageBuilder()
|
||||
.append(name)
|
||||
return new MessageCreateBuilder()
|
||||
.addContent(name)
|
||||
.setEmbeds(
|
||||
new EmbedBuilder()
|
||||
.setThumbnail(thumbnail)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package fr.Skydust.JdrBot.menu;
|
||||
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import fr.Skydust.JdrBot.utils.UnicodeEmotes;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.emoji.Emoji;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageEditData;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -13,7 +15,7 @@ public class MenuSystem {
|
||||
/** Action Listening */
|
||||
public static void onMessageReactionAdd(MessageReactionAddEvent e) {
|
||||
if (e.getChannel() instanceof TextChannel) {
|
||||
if(e.getUser().isBot())
|
||||
if(e.getUser() != null && e.getUser().isBot())
|
||||
return;
|
||||
|
||||
e.getChannel().retrieveMessageById(e.getMessageId()).queue(msg -> {
|
||||
@@ -26,14 +28,16 @@ public class MenuSystem {
|
||||
|
||||
// Check if the emote is valid and get id
|
||||
int emoteId = 0;
|
||||
for(String s : Utils.CharsUnicodeArray){
|
||||
if(s.equals(e.getReaction().getReactionEmote().getEmoji().replace("(null)","").replace("RE:",""))) {
|
||||
for(String emote : UnicodeEmotes.CharsUnicodeArray){
|
||||
String cleanedUpEmote = UnicodeEmotes.cleanUpDiscordEmote(
|
||||
e.getReaction().getEmoji().getAsReactionCode());
|
||||
if(emote.equals(cleanedUpEmote)) {
|
||||
break;
|
||||
}
|
||||
emoteId++;
|
||||
}
|
||||
// Do not proceed if not valid
|
||||
if(emoteId > Utils.CharsUnicodeArray.length) {
|
||||
if(emoteId > UnicodeEmotes.CharsUnicodeArray.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +54,7 @@ public class MenuSystem {
|
||||
System.out.println("Error: No menu on this message");
|
||||
return;
|
||||
}
|
||||
currentMessage.editMessage(newMenu.makeMessage()).queue();
|
||||
currentMessage.editMessage(MessageEditData.fromCreateData(newMenu.makeMessage())).queue();
|
||||
updateReactions(currentMessage, newMenu);
|
||||
}
|
||||
|
||||
@@ -61,7 +65,7 @@ public class MenuSystem {
|
||||
}
|
||||
// Adds missing reactions
|
||||
for (int i = msg.getReactions().size(); i < menu.items.length; i++) {
|
||||
msg.addReaction(Utils.CharsUnicodeArray[i]).queue();
|
||||
msg.addReaction(Emoji.fromUnicode(UnicodeEmotes.CharsUnicodeArray[i])).queue();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +77,7 @@ public class MenuSystem {
|
||||
return;
|
||||
}
|
||||
|
||||
currentMessage.editMessage(newMenu.makeMessage()).queue();
|
||||
currentMessage.editMessage(MessageEditData.fromCreateData(newMenu.makeMessage())).queue();
|
||||
updateReactions(currentMessage, newMenu);
|
||||
menuHash.put(currentMessage, newMenu);
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package fr.Skydust.JdrBot.stock;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public abstract class Command {
|
||||
public String cmdName;
|
||||
public String cmdDesc;
|
||||
public String cmdUsage = "";
|
||||
public boolean hidden = false;
|
||||
|
||||
public abstract void call(MessageReceivedEvent e);
|
||||
|
||||
public void Hide() {
|
||||
hidden = true;
|
||||
}
|
||||
|
||||
public void SetName(String name) {
|
||||
this.cmdName = name;
|
||||
}
|
||||
|
||||
public void SetDesc(String desc) {
|
||||
this.cmdDesc = desc;
|
||||
}
|
||||
|
||||
public void SetUsage(String usage) {
|
||||
this.cmdUsage = usage;
|
||||
}
|
||||
}
|
||||
@@ -5,16 +5,15 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.utils.FileUpload;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
import net.lingala.zip4j.model.ZipParameters;
|
||||
import net.lingala.zip4j.model.enums.CompressionLevel;
|
||||
import net.lingala.zip4j.model.enums.CompressionMethod;
|
||||
import org.apache.commons.codec.EncoderException;
|
||||
import ws.schild.jave.Encoder;
|
||||
import ws.schild.jave.MultimediaObject;
|
||||
import ws.schild.jave.encode.AudioAttributes;
|
||||
@@ -26,7 +25,6 @@ import javax.sound.sampled.AudioInputStream;
|
||||
import javax.sound.sampled.AudioSystem;
|
||||
|
||||
public class RecordState {
|
||||
private static final int RECORDER_SAMPLERATE = 44100;
|
||||
public boolean isRecording;
|
||||
private ByteArrayOutputStream recordData;
|
||||
public boolean isProcessing;
|
||||
@@ -61,7 +59,7 @@ public class RecordState {
|
||||
}
|
||||
}
|
||||
|
||||
public void endRecord(Guild g, MessageChannel tc) {
|
||||
public void endRecord(Guild g, TextChannel tc) {
|
||||
isRecording = false;
|
||||
isProcessing = true;
|
||||
|
||||
@@ -86,7 +84,7 @@ public class RecordState {
|
||||
}).start();
|
||||
}
|
||||
|
||||
public void processRecording(MessageChannel tc) throws IOException, IllegalArgumentException, EncoderException, ws.schild.jave.EncoderException {
|
||||
public void processRecording(TextChannel tc) throws IOException, IllegalArgumentException, ws.schild.jave.EncoderException {
|
||||
//BigEndian, 16 bit signed, 44100hz
|
||||
String OriginalName = new Date().toString().replaceAll(":", "-");
|
||||
|
||||
@@ -130,12 +128,14 @@ public class RecordState {
|
||||
tc.sendMessage("Envoi du fichier audio(Via plusieurs fichiers zip)...").queue();
|
||||
for(Object file : zipFile.getSplitZipFiles()) {
|
||||
File currentFile = new File(file+"");
|
||||
tc.sendFile(currentFile, "").queue(msg -> currentFile.delete());
|
||||
FileUpload fileUpload = FileUpload.fromData(currentFile, currentFile.getName());
|
||||
tc.sendFiles(fileUpload).queue(msg -> currentFile.delete());
|
||||
}
|
||||
} else {
|
||||
tc.sendMessage("Envoi du fichier audio(Via un fichier zip)...").queue();
|
||||
File currentFile = new File(zipFile.getSplitZipFiles().get(0)+"");
|
||||
tc.sendFile(currentFile, currentFile.getName()).queue(msg -> currentFile.delete());
|
||||
FileUpload fileUpload = FileUpload.fromData(currentFile, currentFile.getName());
|
||||
tc.sendFiles(fileUpload).queue(msg -> currentFile.delete());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package fr.Skydust.JdrBot.utils;
|
||||
package fr.Skydust.JdrBot.tasks;
|
||||
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||
30
src/main/java/fr/Skydust/JdrBot/utils/DurationUtils.java
Normal file
30
src/main/java/fr/Skydust/JdrBot/utils/DurationUtils.java
Normal file
@@ -0,0 +1,30 @@
|
||||
package fr.Skydust.JdrBot.utils;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class DurationUtils {
|
||||
|
||||
public static String formatDuration(Duration duration) {
|
||||
long seconds = duration.getSeconds();
|
||||
long absSeconds = Math.abs(seconds);
|
||||
String positive = String.format(
|
||||
"%d:%02d:%02d",
|
||||
absSeconds / 3600,
|
||||
(absSeconds % 3600) / 60,
|
||||
absSeconds % 60);
|
||||
return seconds < 0 ? "-" + positive : positive;
|
||||
}
|
||||
|
||||
public static String formatDurationSmooth(Duration duration) {
|
||||
long absSeconds = Math.abs(duration.getSeconds());
|
||||
|
||||
if((absSeconds/3600) == 0) {//Hours
|
||||
if(((absSeconds%3600)/60) == 0)
|
||||
{//Minutes
|
||||
return String.format("%d secondes", absSeconds % 60);
|
||||
}
|
||||
return String.format("%d minutes", (absSeconds % 3600) / 60);
|
||||
}
|
||||
return String.format("%d heures", (absSeconds /3600));
|
||||
}
|
||||
}
|
||||
19
src/main/java/fr/Skydust/JdrBot/utils/UnicodeEmotes.java
Normal file
19
src/main/java/fr/Skydust/JdrBot/utils/UnicodeEmotes.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package fr.Skydust.JdrBot.utils;
|
||||
|
||||
public class UnicodeEmotes {
|
||||
/*0to10*/
|
||||
public static final String[] CharsUnicodeArray = {"\u0030\u20E3","\u0031\u20E3","\u0032\u20E3","\u0033\u20E3","\u0034\u20E3","\u0035\u20E3","\u0036\u20E3","\u0037\u20E3","\u0038\u20E3","\u0039\u20E3","\uD83D\uDD1F",
|
||||
/*Alphabet*/ "\uD83C\uDDE6","\uD83C\uDDE7","\uD83C\uDDE8","\uD83C\uDDE9","\uD83C\uDDEA","\uD83C\uDDEB","\uD83C\uDDEC","\uD83C\uDDED","\uD83C\uDDEE","\uD83C\uDDEF","\uD83C\uDDF0","\uD83C\uDDF1","\uD83C\uDDF2","\uD83C\uDDF3","\uD83C\uDDF4","\uD83C\uDDF5","\uD83C\uDDF6","\uD83C\uDDF7","\uD83C\uDDF8","\uD83C\uDDF9","\uD83C\uDDFA","\uD83C\uDDFB","\uD83C\uDDFC","\uD83C\uDDFD","\uD83C\uDDFE","\uD83C\uDDFF"};
|
||||
|
||||
public static final String PlayUnicode = "\uD83D\uDD09";
|
||||
public static final String SongUnicode = "\uD83C\uDFB5";
|
||||
public static final String FolderUnicode = "\uD83D\uDCC1";
|
||||
public static final String ReturnUnicode = "\uD83D\uDCC2";
|
||||
|
||||
public static final String ProgressBarForeground = "\uD83D\uDFE9";
|
||||
public static final String ProgressBarBackground = "\u2B1C";
|
||||
|
||||
public static String cleanUpDiscordEmote(String discordReactionString) {
|
||||
return discordReactionString.replace("(null)","").replace("RE:","");
|
||||
}
|
||||
}
|
||||
@@ -1,59 +1,35 @@
|
||||
package fr.Skydust.JdrBot.utils;
|
||||
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
import fr.Skydust.JdrBot.enums.MessageType;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
|
||||
import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.Duration;
|
||||
|
||||
public class Utils {
|
||||
/*0to10*/
|
||||
public static final String[] CharsUnicodeArray = {"\u0030\u20E3","\u0031\u20E3","\u0032\u20E3","\u0033\u20E3","\u0034\u20E3","\u0035\u20E3","\u0036\u20E3","\u0037\u20E3","\u0038\u20E3","\u0039\u20E3","\uD83D\uDD1F",
|
||||
/*Alphabet*/ "\uD83C\uDDE6","\uD83C\uDDE7","\uD83C\uDDE8","\uD83C\uDDE9","\uD83C\uDDEA","\uD83C\uDDEB","\uD83C\uDDEC","\uD83C\uDDED","\uD83C\uDDEE","\uD83C\uDDEF","\uD83C\uDDF0","\uD83C\uDDF1","\uD83C\uDDF2","\uD83C\uDDF3","\uD83C\uDDF4","\uD83C\uDDF5","\uD83C\uDDF6","\uD83C\uDDF7","\uD83C\uDDF8","\uD83C\uDDF9","\uD83C\uDDFA","\uD83C\uDDFB","\uD83C\uDDFC","\uD83C\uDDFD","\uD83C\uDDFE","\uD83C\uDDFF"};
|
||||
|
||||
public static final String PlayUnicode = "\uD83D\uDD09";
|
||||
public static final String SongUnicode = "\uD83C\uDFB5";
|
||||
public static final String FolderUnicode = "\uD83D\uDCC1";
|
||||
public static final String ReturnUnicode = "\uD83D\uDCC2";
|
||||
|
||||
public static final String ProgressBarForeground = "\uD83D\uDFE9";
|
||||
public static final String ProgressBarBackground = "\u2B1C";
|
||||
|
||||
public static boolean IsInt(String info) {
|
||||
/**
|
||||
* Simple function to check if a string is parseable as an integer.
|
||||
* @param str The string to try to parse.
|
||||
* @return True is the string is parseable, false otherwise.
|
||||
*/
|
||||
public static boolean IsInt(String str) {
|
||||
try {
|
||||
Integer.parseInt(info);
|
||||
Integer.parseInt(str);
|
||||
return true;
|
||||
} catch(Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public static String formatDuration(Duration duration) {
|
||||
long seconds = duration.getSeconds();
|
||||
long absSeconds = Math.abs(seconds);
|
||||
String positive = String.format(
|
||||
"%d:%02d:%02d",
|
||||
absSeconds / 3600,
|
||||
(absSeconds % 3600) / 60,
|
||||
absSeconds % 60);
|
||||
return seconds < 0 ? "-" + positive : positive;
|
||||
}
|
||||
|
||||
public static String formatDurationSmooth(Duration duration) {
|
||||
long absSeconds = Math.abs(duration.getSeconds());
|
||||
|
||||
if((absSeconds/3600) == 0) {//Hours
|
||||
if(((absSeconds%3600)/60) == 0)
|
||||
{//Minutes
|
||||
return String.format("%d secondes", absSeconds % 60);
|
||||
}
|
||||
return String.format("%d minutes", (absSeconds % 3600) / 60);
|
||||
}
|
||||
return String.format("%d heures", (absSeconds /3600));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An utility function to send a message into a discord channel.
|
||||
* @param channel The channel to send the message to.
|
||||
* @param msgType The type of message to send.
|
||||
* @param message The message.
|
||||
*/
|
||||
public static void sendMessage(MessageChannel channel, MessageType msgType, String message) {
|
||||
Color c = Color.GREEN;
|
||||
String title = "Message";
|
||||
@@ -63,7 +39,7 @@ public class Utils {
|
||||
title = "Erreur";
|
||||
}
|
||||
|
||||
channel.sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder().
|
||||
channel.sendMessage(new MessageCreateBuilder().setEmbeds(new EmbedBuilder().
|
||||
setDescription(message)
|
||||
.setTitle(title, null)
|
||||
.setFooter("", JdrBot.jda.getSelfUser().getAvatarUrl())
|
||||
|
||||
Reference in New Issue
Block a user