Version 3.1:
Updated multiple libraries. Updated JDA to use its alpha version and updated the code accordingly.
This commit is contained in:
14
build.gradle
14
build.gradle
@@ -30,18 +30,16 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// This dependency is used by the application.//
|
implementation 'com.google.guava:guava:31.1-jre'
|
||||||
implementation 'com.google.guava:guava:31.0.1-jre'
|
implementation 'com.github.oshi:oshi-core:6.1.6'
|
||||||
//implementation 'org.slf4j:slf4j-log4j12:2.0.0-alpha0'
|
implementation 'com.github.oshi:oshi-json:3.13.6'
|
||||||
implementation 'org.slf4j:slf4j-simple:2.0.0-alpha0'
|
implementation 'org.slf4j:slf4j-simple:2.0.0-alpha0'
|
||||||
|
implementation 'net.lingala.zip4j:zip4j:2.10.0'
|
||||||
implementation 'net.lingala.zip4j:zip4j:2.9.1'
|
|
||||||
implementation 'club.minnced:opus-java:1.1.1'
|
implementation 'club.minnced:opus-java:1.1.1'
|
||||||
|
implementation 'ws.schild:jave-all-deps:3.3.1'
|
||||||
implementation 'ws.schild:jave-all-deps:3.1.1'
|
|
||||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||||
implementation 'com.sedmelluq:lavaplayer:1.3.78'
|
implementation 'com.sedmelluq:lavaplayer:1.3.78'
|
||||||
implementation 'com.github.DV8FromTheWorld:JDA:4.4.0'
|
implementation 'com.github.DV8FromTheWorld:JDA:5.0.0-alpha.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
application {
|
application {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package fr.Skydust.JdrBot;
|
|||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
@@ -20,7 +19,7 @@ import net.dv8tion.jda.api.entities.Activity;
|
|||||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||||
|
|
||||||
public class JdrBot {
|
public class JdrBot {
|
||||||
public static String Version = "3.0";
|
public static String Version = "3.1";
|
||||||
|
|
||||||
public static JDA jda;
|
public static JDA jda;
|
||||||
public static LocalDateTime basedate;
|
public static LocalDateTime basedate;
|
||||||
@@ -28,6 +27,8 @@ public class JdrBot {
|
|||||||
|
|
||||||
public static String startcmdchar = "!|:";
|
public static String startcmdchar = "!|:";
|
||||||
|
|
||||||
|
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++) {
|
for (int i=0;i<args.length;i++) {
|
||||||
if(args[i].equalsIgnoreCase("--heartbeat")) {
|
if(args[i].equalsIgnoreCase("--heartbeat")) {
|
||||||
@@ -36,13 +37,17 @@ public class JdrBot {
|
|||||||
return; // Quits the program
|
return; // Quits the program
|
||||||
}
|
}
|
||||||
//"zabbix_sender -z localhost -s \"Lustricru\" -k discordBots.potatos.ping -o {ping}"
|
//"zabbix_sender -z localhost -s \"Lustricru\" -k discordBots.potatos.ping -o {ping}"
|
||||||
String command = String.join("", Arrays.copyOfRange(args,i+1,args.length));
|
|
||||||
|
|
||||||
if(command.startsWith("\"")) command = command.split("\"")[1]; // If the command is in "", remove them
|
String command = args[i+1];
|
||||||
|
//SkipCMD
|
||||||
|
i++;
|
||||||
|
|
||||||
new Timer().scheduleAtFixedRate(new HeartbeatTask(command),1000, 60000);
|
new Timer().scheduleAtFixedRate(new HeartbeatTask(command),1000, 60000);
|
||||||
|
|
||||||
System.out.println("Registered Heartbeat Command: "+command);
|
System.out.println("Registered Heartbeat Command: "+command);
|
||||||
|
} else if(args[i].equalsIgnoreCase("--debug")) {
|
||||||
|
debugMode = true;
|
||||||
|
System.out.println("Warning: the bot is in debug mode");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,9 +55,9 @@ public class JdrBot {
|
|||||||
basedate = LocalDateTime.now();
|
basedate = LocalDateTime.now();
|
||||||
|
|
||||||
// Prod Bot
|
// Prod Bot
|
||||||
//String token = "MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM";
|
String token = "MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM";
|
||||||
// Test Bot
|
// Test Bot
|
||||||
String token = "ODk0ODc0Nzk5Nzg3MTE0NTA2.YVwXGg.JfIsIIQHIXbVsjoGGv2SfejnT9s";
|
//String token = "ODk0ODc0Nzk5Nzg3MTE0NTA2.YVwXGg.JfIsIIQHIXbVsjoGGv2SfejnT9s";
|
||||||
|
|
||||||
jda = JDABuilder.createDefault(token)
|
jda = JDABuilder.createDefault(token)
|
||||||
.setActivity(Activity.playing("un jeu de rôle"))
|
.setActivity(Activity.playing("un jeu de rôle"))
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ import fr.Skydust.JdrBot.utils.HeartbeatTask;
|
|||||||
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
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.GuildVoiceMoveEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||||
import net.dv8tion.jda.api.events.user.update.UserUpdateOnlineStatusEvent;
|
import net.dv8tion.jda.api.events.user.update.UserUpdateOnlineStatusEvent;
|
||||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
|
|
||||||
public class JdrBotListener extends ListenerAdapter {
|
public class JdrBotListener extends ListenerAdapter {
|
||||||
@Override
|
@Override
|
||||||
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
public void onMessageReceived(MessageReceivedEvent e) {
|
||||||
// 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;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import net.dv8tion.jda.api.audio.UserAudio;
|
|||||||
public class JdrBotARH implements AudioReceiveHandler {
|
public class JdrBotARH implements AudioReceiveHandler {
|
||||||
private final RecordState recordState;
|
private final RecordState recordState;
|
||||||
|
|
||||||
String guild;
|
|
||||||
public JdrBotARH(RecordState rs) {
|
public JdrBotARH(RecordState rs) {
|
||||||
this.recordState = rs;
|
this.recordState = rs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package fr.Skydust.JdrBot.cmds;
|
package fr.Skydust.JdrBot.cmds;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class AddSong extends Command {
|
public class AddSong extends Command {
|
||||||
public AddSong() {
|
public AddSong() {
|
||||||
@@ -11,7 +11,7 @@ public class AddSong extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
|
|
||||||
//TODO: Chemin sans le chemin initial
|
//TODO: Chemin sans le chemin initial
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import fr.Skydust.JdrBot.JdrBot;
|
|||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -17,7 +17,7 @@ public class Aide extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent 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++)
|
||||||
@@ -28,7 +28,7 @@ public class Aide extends Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
e.getChannel().sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder()
|
e.getChannel().sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder()
|
||||||
.setDescription(sb.toString())
|
.setDescription(sb.toString())
|
||||||
.setTitle("Aide", null)
|
.setTitle("Aide", null)
|
||||||
.setFooter("Fait le " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy 'a' HH:mm:ss")), e.getJDA().getSelfUser().getAvatarUrl())
|
.setFooter("Fait le " + LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy 'a' HH:mm:ss")), e.getJDA().getSelfUser().getAvatarUrl())
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package fr.Skydust.JdrBot.cmds;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class Emote extends Command {
|
public class Emote extends Command {
|
||||||
public Emote() {
|
public Emote() {
|
||||||
@@ -12,7 +12,7 @@ public class Emote extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
String[] args = Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length);
|
String[] args = Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length);
|
||||||
|
|
||||||
String str = args[0];
|
String str = args[0];
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.text.DecimalFormat;
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary;
|
import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary;
|
||||||
import fr.Skydust.JdrBot.JdrBot;
|
import fr.Skydust.JdrBot.JdrBot;
|
||||||
@@ -14,56 +15,55 @@ import fr.Skydust.JdrBot.utils.Utils;
|
|||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.JDAInfo;
|
import net.dv8tion.jda.api.JDAInfo;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
import oshi.SystemInfo;
|
||||||
|
import oshi.hardware.HardwareAbstractionLayer;
|
||||||
|
|
||||||
public class Etat extends Command {
|
public class Etat extends Command {
|
||||||
|
private static final DecimalFormat df = new DecimalFormat("###.##");
|
||||||
|
|
||||||
public Etat() {
|
public Etat() {
|
||||||
SetName("status");
|
SetName("status");
|
||||||
SetDesc("Donne le status du bot");
|
SetDesc("Donne le status du bot et du serveur");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
|
SystemInfo si = new SystemInfo();
|
||||||
//StringBuilder sb = new StringBuilder();
|
HardwareAbstractionLayer hal = si.getHardware();
|
||||||
//SystemInfo si = new SystemInfo();
|
|
||||||
//HardwareAbstractionLayer hal = si.getHardware();
|
|
||||||
Runtime rt = Runtime.getRuntime();
|
Runtime rt = Runtime.getRuntime();
|
||||||
DecimalFormat df = new DecimalFormat("#.##");
|
DecimalFormat df = new DecimalFormat("###.##");
|
||||||
/*sb.append("------------------------------------\n");
|
|
||||||
sb.append("**CPU** (Current/Average): "+ + "\n**Threads**: "++ "\n");
|
|
||||||
sb.append("**Memory** (Used/Total):"
|
|
||||||
+ "\n Principal: "+(df.format((hal.getMemory().getTotal()-hal.getMemory().getAvailable())/1024/1024))+"Mb/"+df.format(hal.getMemory().getTotal()/1024/1024)+"Mb"
|
|
||||||
+ "\n JVM: "+((rt.totalMemory()-rt.freeMemory())/1024/1024)+"Mb/"+(rt.totalMemory()/1024/1024)+"Mb"
|
|
||||||
+ "\n Swap: "+df.format(hal.getMemory().getSwapUsed()/1024/1024)+"Mb/"+df.format(hal.getMemory().getSwapTotal()/1024/1024)+"Mb\n"
|
|
||||||
+ "\n");
|
|
||||||
sb.append("**Servers**: "+e.getJDA().getGuilds().size()+"\n");
|
|
||||||
sb.append("**Servers w/ Music Started**: "+PlayMusic.musicManagers.size()+"\n");
|
|
||||||
sb.append("**Servers w/ Recording Started**: "+Record.rbs.size()+"\n");*/
|
|
||||||
LocalDateTime currentDate = LocalDateTime.now();
|
LocalDateTime currentDate = LocalDateTime.now();
|
||||||
Duration difference = Duration.between(JdrBot.basedate, currentDate);
|
Duration difference = Duration.between(JdrBot.basedate, currentDate);
|
||||||
//sb.append("**Uptime**: "+Utils.formatDuration(difference));
|
|
||||||
|
|
||||||
|
e.getChannel().sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder()
|
||||||
e.getChannel().sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder()
|
|
||||||
.setAuthor("Etat de "+ e.getGuild().getSelfMember().getEffectiveName())
|
.setAuthor("Etat de "+ e.getGuild().getSelfMember().getEffectiveName())
|
||||||
.addBlankField(false)
|
.addBlankField(false)
|
||||||
//.addField("CPU","-----", false)
|
.addField("CPU","-----", false)
|
||||||
//.addField("Load (Current/Average)",df.format(hal.getProcessor().getSystemCpuLoad()*100)+"%/"+df.format(hal.getProcessor().getSystemLoadAverage()*100)+"%",false)
|
.addField("Load (Current/Average)",df.format(hal.getProcessor().getSystemCpuLoad()*100) +"%/"+ df.format(hal.getProcessor().getSystemLoadAverage()*100) +"%",false)
|
||||||
//.addField("CPU Temperature", String.format("%.1f°C", hal.getSensors().getCpuTemperature()), true)
|
.addField("CPU Temperature", String.format("%.1f°C", hal.getSensors().getCpuTemperature()), true)
|
||||||
//.addField("Fan Speed", Arrays.toString(hal.getSensors().getFanSpeeds()), true)
|
.addField("Fan Speed", Arrays.toString(hal.getSensors().getFanSpeeds()), true)
|
||||||
.addField("Threads", ManagementFactory.getThreadMXBean().getThreadCount()+"", true)
|
.addField("Threads", ManagementFactory.getThreadMXBean().getThreadCount()+"", true)
|
||||||
.addBlankField(false)
|
.addBlankField(false)
|
||||||
.addField("Memory (Used/Total)", "-----",false)
|
.addField("Memory (Used/Total)", "-----",false)
|
||||||
//.addField("Principal",(df.format((hal.getMemory().getTotal()-hal.getMemory().getAvailable())/1024/1024))+"Mb/"+df.format(hal.getMemory().getTotal()/1024/1024)+"Mb", true)
|
.addField("Principal",convertAndFormat(hal.getMemory().getTotal()-hal.getMemory().getAvailable()) +"Mb/"+ convertAndFormat(hal.getMemory().getTotal())+"Mb", true)
|
||||||
.addField("JVM",((rt.totalMemory()-rt.freeMemory())/1024/1024)+"Mb/"+(rt.totalMemory()/1024/1024)+"Mb", true)
|
.addField("JVM", convertAndFormat(rt.totalMemory()-rt.freeMemory())+"Mb/"+ convertAndFormat(rt.totalMemory()) +"Mb", true)
|
||||||
//.addField("Swap",df.format(hal.getMemory().getSwapUsed()/1024/1024)+"Mb/"+df.format(hal.getMemory().getSwapTotal()/1024/1024)+"Mb", true)
|
.addField("Swap", convertAndFormat(hal.getMemory().getSwapUsed()) + "Mb/"+ convertAndFormat(hal.getMemory().getSwapTotal()) +"Mb", true)
|
||||||
.addBlankField(false)
|
.addBlankField(false)
|
||||||
.addField("Servers",e.getJDA().getGuilds().size()+"",true)
|
.addField("Servers",e.getJDA().getGuilds().size()+"",true)
|
||||||
.addField("Versions", "JdrBot: "+JdrBot.Version+ " - JDA: " + JDAInfo.VERSION + " - Lavaplayer: "+ PlayerLibrary.VERSION, true)
|
.addField("Versions", "JdrBot: "+ JdrBot.Version +" - JDA: "+ JDAInfo.VERSION +" - Lavaplayer: "+ PlayerLibrary.VERSION, true)
|
||||||
.addField("Uptime", Utils.formatDuration(difference), true)
|
.addField("Uptime", Utils.formatDuration(difference), true)
|
||||||
.setFooter("*Fait le "+currentDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy à HH:mm:ss"))+"*", e.getJDA().getSelfUser().getAvatarUrl())
|
.setFooter("*Fait le "+ currentDate.format(DateTimeFormatter.ofPattern("dd/MM/yyyy à HH:mm:ss")) +"*", e.getJDA().getSelfUser().getAvatarUrl())
|
||||||
.setColor(Color.BLUE)
|
.setColor(Color.BLUE)
|
||||||
.build()).build()).queue();
|
.build()).build()).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static long octetToMegabytes(long input) {
|
||||||
|
return input/1048576;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String convertAndFormat(long octets) {
|
||||||
|
return df.format(octetToMegabytes(octets));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import fr.Skydust.JdrBot.stock.Command;
|
import fr.Skydust.JdrBot.stock.Command;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class Roll extends Command {
|
public class Roll extends Command {
|
||||||
static Random r = new Random();
|
static Random r = new Random();
|
||||||
@@ -15,7 +15,7 @@ public class Roll extends Command {
|
|||||||
SetUsage("[NombreDés]d[NombreFaces] OU [NombreFaces]");
|
SetUsage("[NombreDés]d[NombreFaces] OU [NombreFaces]");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
if (e.getMessage().getContentRaw().split(" ").length != 1)
|
if (e.getMessage().getContentRaw().split(" ").length != 1)
|
||||||
{
|
{
|
||||||
String[] args = e.getMessage().getContentRaw().split(" ");
|
String[] args = e.getMessage().getContentRaw().split(" ");
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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.MessageType;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -17,14 +17,14 @@ public class FLoad extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||||
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length), " ");
|
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.getGuild(), e.getChannel(), args, false, false);
|
||||||
|
|
||||||
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Forçage du lancement de "+args);
|
Utils.sendMessage(e.getChannel(), MessageType.NORMAL, "Forçage du lancement de "+args);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ 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.MessageType;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -17,7 +17,7 @@ public class FLoadLoop extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||||
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length)," ");
|
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length)," ");
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ public class FLoadLoop extends Command {
|
|||||||
if(!args.matches(".*(https?)://.*")) {
|
if(!args.matches(".*(https?)://.*")) {
|
||||||
args = "ytsearch:"+args;
|
args = "ytsearch:"+args;
|
||||||
}
|
}
|
||||||
PlayMusic.loadAndPlay(e.getChannel(), StringUtils.join(args," "), true, false);
|
PlayMusic.loadAndPlay(e.getGuild(), e.getChannel(), StringUtils.join(args," "), true, false);
|
||||||
} else {
|
} else {
|
||||||
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes dans un salon vocal");
|
Utils.sendMessage(e.getChannel(), MessageType.ERROR, "Vous n'êtes dans un salon vocal");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package fr.Skydust.JdrBot.cmds.playmusic;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack;
|
|
||||||
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
import fr.Skydust.JdrBot.jukebox.JukeboxSystem;
|
||||||
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.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||||
@@ -37,7 +36,7 @@ public class PlayMusic extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
if(!e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
if(!e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,7 +46,7 @@ public class PlayMusic extends Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!e.getMember().getVoiceState().inVoiceChannel()) {
|
if(!e.getMember().getVoiceState().inAudioChannel()) {
|
||||||
e.getChannel().sendMessage("/!\\ Vous devez être dans un channel vocal").queue();
|
e.getChannel().sendMessage("/!\\ Vous devez être dans un channel vocal").queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -65,10 +64,10 @@ public class PlayMusic extends Command {
|
|||||||
return jukeboxSystems.get(guild.getIdLong());
|
return jukeboxSystems.get(guild.getIdLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAndPlay(final TextChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
public static void loadAndPlay(final Guild guild, final MessageChannel channel, final String trackUrl, boolean loop, boolean nomsg) {
|
||||||
System.out.println(trackUrl);
|
System.out.println(trackUrl);
|
||||||
|
|
||||||
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
GuildMusicManager musicManager = getGuildAudioPlayer(guild);
|
||||||
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
|
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void trackLoaded(AudioTrack track) {
|
public void trackLoaded(AudioTrack track) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.dv8tion.jda.api.Permission;
|
|||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
|
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.GuildVoiceMoveEvent;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class StopMusic extends Command {
|
public class StopMusic extends Command {
|
||||||
public StopMusic() {
|
public StopMusic() {
|
||||||
@@ -16,7 +16,7 @@ public class StopMusic extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
if(!e.getGuild().getAudioManager().isConnected() || !e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
if(!e.getGuild().getAudioManager().isConnected() || !e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import fr.Skydust.JdrBot.stock.Command;
|
|||||||
import fr.Skydust.JdrBot.stock.RecordState;
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import fr.Skydust.JdrBot.utils.MessageType;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class CancelRecord extends Command {
|
public class CancelRecord extends Command {
|
||||||
public CancelRecord() {
|
public CancelRecord() {
|
||||||
@@ -14,7 +14,7 @@ public class CancelRecord extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
if(rs.isRecording) {
|
if(rs.isRecording) {
|
||||||
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ 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;
|
||||||
@@ -11,7 +10,7 @@ import fr.Skydust.JdrBot.utils.MessageType;
|
|||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.Permission;
|
import net.dv8tion.jda.api.Permission;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class Record extends Command {
|
public class Record extends Command {
|
||||||
public static HashMap<Long, RecordState> recordStates = new HashMap<>();
|
public static HashMap<Long, RecordState> recordStates = new HashMap<>();
|
||||||
@@ -22,7 +21,7 @@ public class Record extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e)
|
public void call(MessageReceivedEvent e)
|
||||||
{
|
{
|
||||||
if(e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
if(e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||||
RecordState currentRS = getGuildRecordState(e.getGuild());
|
RecordState currentRS = getGuildRecordState(e.getGuild());
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import fr.Skydust.JdrBot.stock.Command;
|
|||||||
import fr.Skydust.JdrBot.stock.RecordState;
|
import fr.Skydust.JdrBot.stock.RecordState;
|
||||||
import fr.Skydust.JdrBot.utils.MessageType;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
import fr.Skydust.JdrBot.utils.Utils;
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public class StopRecord extends Command {
|
public class StopRecord extends Command {
|
||||||
public StopRecord() {
|
public StopRecord() {
|
||||||
@@ -14,7 +14,7 @@ public class StopRecord extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void call(GuildMessageReceivedEvent e) {
|
public void call(MessageReceivedEvent e) {
|
||||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||||
if(rs.isRecording) {
|
if(rs.isRecording) {
|
||||||
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class JukeboxSystem {
|
|||||||
|
|
||||||
String songPath = currentFolder + "/" + getFileNameFromItem(str) + ".mp3";
|
String songPath = currentFolder + "/" + getFileNameFromItem(str) + ".mp3";
|
||||||
|
|
||||||
PlayMusic.loadAndPlay(msg.getTextChannel(), songPath, true, true);
|
PlayMusic.loadAndPlay(msg.getGuild(), msg.getTextChannel(), songPath, true, true);
|
||||||
|
|
||||||
// Format: Songs/Folder/SubFolder/2
|
// Format: Songs/Folder/SubFolder/2
|
||||||
songPlayedPath = currentFolder + "/" + itemId;
|
songPlayedPath = currentFolder + "/" + itemId;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class Menu {
|
|||||||
|
|
||||||
return new MessageBuilder()
|
return new MessageBuilder()
|
||||||
.append(name)
|
.append(name)
|
||||||
.setEmbed(
|
.setEmbeds(
|
||||||
new EmbedBuilder()
|
new EmbedBuilder()
|
||||||
.setThumbnail(thumbnail)
|
.setThumbnail(thumbnail)
|
||||||
.setTitle(title,null)
|
.setTitle(title,null)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package fr.Skydust.JdrBot.stock;
|
package fr.Skydust.JdrBot.stock;
|
||||||
|
|
||||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||||
|
|
||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
public String cmdName;
|
public String cmdName;
|
||||||
@@ -8,7 +8,7 @@ public abstract class Command {
|
|||||||
public String cmdUsage = "";
|
public String cmdUsage = "";
|
||||||
public boolean hidden = false;
|
public boolean hidden = false;
|
||||||
|
|
||||||
public abstract void call(GuildMessageReceivedEvent e);
|
public abstract void call(MessageReceivedEvent e);
|
||||||
|
|
||||||
public void Hide() {
|
public void Hide() {
|
||||||
hidden = true;
|
hidden = true;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import fr.Skydust.JdrBot.utils.MessageType;
|
import fr.Skydust.JdrBot.utils.MessageType;
|
||||||
import fr.Skydust.JdrBot.utils.Utils;
|
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.MessageChannel;
|
||||||
import net.dv8tion.jda.api.entities.TextChannel;
|
import net.dv8tion.jda.api.entities.TextChannel;
|
||||||
import net.lingala.zip4j.ZipFile;
|
import net.lingala.zip4j.ZipFile;
|
||||||
import net.lingala.zip4j.model.ZipParameters;
|
import net.lingala.zip4j.model.ZipParameters;
|
||||||
@@ -60,7 +61,7 @@ public class RecordState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void endRecord(Guild g, TextChannel tc) {
|
public void endRecord(Guild g, MessageChannel tc) {
|
||||||
isRecording = false;
|
isRecording = false;
|
||||||
isProcessing = true;
|
isProcessing = true;
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@ public class RecordState {
|
|||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processRecording(TextChannel tc) throws IOException, IllegalArgumentException, EncoderException, ws.schild.jave.EncoderException {
|
public void processRecording(MessageChannel tc) throws IOException, IllegalArgumentException, EncoderException, ws.schild.jave.EncoderException {
|
||||||
//BigEndian, 16 bit signed, 44100hz
|
//BigEndian, 16 bit signed, 44100hz
|
||||||
String OriginalName = new Date().toString().replaceAll(":", "-");
|
String OriginalName = new Date().toString().replaceAll(":", "-");
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ package fr.Skydust.JdrBot.utils;
|
|||||||
import fr.Skydust.JdrBot.JdrBot;
|
import fr.Skydust.JdrBot.JdrBot;
|
||||||
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Scanner;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
public class HeartbeatTask extends TimerTask {
|
public class HeartbeatTask extends TimerTask {
|
||||||
@@ -19,7 +22,14 @@ public class HeartbeatTask extends TimerTask {
|
|||||||
long ping = JdrBot.jda.getGatewayPing();
|
long ping = JdrBot.jda.getGatewayPing();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Runtime.getRuntime().exec(command.replaceAll("\\{ping\\}", String.valueOf(ping)));
|
Process p = Runtime.getRuntime().exec(command.replaceAll("\\{ping\\}", String.valueOf(ping)));
|
||||||
|
if(JdrBot.debugMode) {
|
||||||
|
try (InputStream inputStream = p.getInputStream(); Scanner s = new Scanner(inputStream).useDelimiter("\\A")) {
|
||||||
|
System.out.println(s.hasNext() ? s.next() : "");
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Error: "+e.getMessage());
|
System.out.println("Error: "+e.getMessage());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package fr.Skydust.JdrBot.utils;
|
|||||||
import fr.Skydust.JdrBot.JdrBot;
|
import fr.Skydust.JdrBot.JdrBot;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
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.TextChannel;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -53,7 +54,7 @@ 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) {
|
public static void sendMessage(MessageChannel channel, MessageType msgType, String message) {
|
||||||
Color c = Color.GREEN;
|
Color c = Color.GREEN;
|
||||||
String title = "Message";
|
String title = "Message";
|
||||||
|
|
||||||
@@ -62,7 +63,7 @@ public class Utils {
|
|||||||
title = "Erreur";
|
title = "Erreur";
|
||||||
}
|
}
|
||||||
|
|
||||||
channel.sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder().
|
channel.sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder().
|
||||||
setDescription(message)
|
setDescription(message)
|
||||||
.setTitle(title, null)
|
.setTitle(title, null)
|
||||||
.setFooter("", JdrBot.jda.getSelfUser().getAvatarUrl())
|
.setFooter("", JdrBot.jda.getSelfUser().getAvatarUrl())
|
||||||
|
|||||||
Reference in New Issue
Block a user