Version 3.1:
Updated multiple libraries. Updated JDA to use its alpha version and updated the code accordingly.
This commit is contained in:
@@ -2,7 +2,6 @@ package fr.Skydust.JdrBot;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import javax.security.auth.login.LoginException;
|
||||
@@ -20,14 +19,16 @@ import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.utils.cache.CacheFlag;
|
||||
|
||||
public class JdrBot {
|
||||
public static String Version = "3.0";
|
||||
public static String Version = "3.1";
|
||||
|
||||
public static JDA jda;
|
||||
public static LocalDateTime basedate;
|
||||
public static List<Command> commandList;
|
||||
|
||||
public static String startcmdchar = "!|:";
|
||||
|
||||
|
||||
public static boolean debugMode = false;
|
||||
|
||||
public static void main(String args[]) {
|
||||
for (int i=0;i<args.length;i++) {
|
||||
if(args[i].equalsIgnoreCase("--heartbeat")) {
|
||||
@@ -36,13 +37,17 @@ public class JdrBot {
|
||||
return; // Quits the program
|
||||
}
|
||||
//"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);
|
||||
|
||||
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();
|
||||
|
||||
// Prod Bot
|
||||
//String token = "MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM";
|
||||
String token = "MTY5OTMzMzgxMDMzOTE4NDY0.DerlJg.m7BdNv_OMHlYa-f4T3O0jJ9LldM";
|
||||
// Test Bot
|
||||
String token = "ODk0ODc0Nzk5Nzg3MTE0NTA2.YVwXGg.JfIsIIQHIXbVsjoGGv2SfejnT9s";
|
||||
//String token = "ODk0ODc0Nzk5Nzg3MTE0NTA2.YVwXGg.JfIsIIQHIXbVsjoGGv2SfejnT9s";
|
||||
|
||||
jda = JDABuilder.createDefault(token)
|
||||
.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.guild.voice.GuildVoiceLeaveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.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;
|
||||
|
||||
public class JdrBotListener extends ListenerAdapter {
|
||||
@Override
|
||||
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
||||
public void onMessageReceived(MessageReceivedEvent e) {
|
||||
// IF it doesn't start with the startcmdchar, ignore for optimization
|
||||
if (!e.getMessage().getContentRaw().matches("^("+ JdrBot.startcmdchar+").*$") || e.getMessage().getAuthor().isBot())
|
||||
return;
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.dv8tion.jda.api.audio.UserAudio;
|
||||
public class JdrBotARH implements AudioReceiveHandler {
|
||||
private final RecordState recordState;
|
||||
|
||||
String guild;
|
||||
public JdrBotARH(RecordState rs) {
|
||||
this.recordState = rs;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package fr.Skydust.JdrBot.cmds;
|
||||
|
||||
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 AddSong() {
|
||||
@@ -11,7 +11,7 @@ public class AddSong extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
|
||||
//TODO: Chemin sans le chemin initial
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import fr.Skydust.JdrBot.JdrBot;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
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.time.LocalDateTime;
|
||||
@@ -17,7 +17,7 @@ public class Aide extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
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())
|
||||
.setTitle("Aide", null)
|
||||
.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 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 Emote() {
|
||||
@@ -12,7 +12,7 @@ public class Emote extends Command {
|
||||
}
|
||||
|
||||
@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 str = args[0];
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.text.DecimalFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary;
|
||||
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.JDAInfo;
|
||||
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 {
|
||||
private static final DecimalFormat df = new DecimalFormat("###.##");
|
||||
|
||||
public Etat() {
|
||||
SetName("status");
|
||||
SetDesc("Donne le status du bot");
|
||||
SetDesc("Donne le status du bot et du serveur");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
|
||||
//StringBuilder sb = new StringBuilder();
|
||||
//SystemInfo si = new SystemInfo();
|
||||
//HardwareAbstractionLayer hal = si.getHardware();
|
||||
public void call(MessageReceivedEvent e) {
|
||||
SystemInfo si = new SystemInfo();
|
||||
HardwareAbstractionLayer hal = si.getHardware();
|
||||
Runtime rt = Runtime.getRuntime();
|
||||
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");*/
|
||||
DecimalFormat df = new DecimalFormat("###.##");
|
||||
|
||||
LocalDateTime currentDate = LocalDateTime.now();
|
||||
Duration difference = Duration.between(JdrBot.basedate, currentDate);
|
||||
//sb.append("**Uptime**: "+Utils.formatDuration(difference));
|
||||
|
||||
|
||||
e.getChannel().sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder()
|
||||
e.getChannel().sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder()
|
||||
.setAuthor("Etat de "+ e.getGuild().getSelfMember().getEffectiveName())
|
||||
.addBlankField(false)
|
||||
//.addField("CPU","-----", 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("Fan Speed", Arrays.toString(hal.getSensors().getFanSpeeds()), true)
|
||||
.addField("CPU","-----", 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("Fan Speed", Arrays.toString(hal.getSensors().getFanSpeeds()), true)
|
||||
.addField("Threads", ManagementFactory.getThreadMXBean().getThreadCount()+"", true)
|
||||
.addBlankField(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("JVM",((rt.totalMemory()-rt.freeMemory())/1024/1024)+"Mb/"+(rt.totalMemory()/1024/1024)+"Mb", true)
|
||||
//.addField("Swap",df.format(hal.getMemory().getSwapUsed()/1024/1024)+"Mb/"+df.format(hal.getMemory().getSwapTotal()/1024/1024)+"Mb", true)
|
||||
.addField("Principal",convertAndFormat(hal.getMemory().getTotal()-hal.getMemory().getAvailable()) +"Mb/"+ convertAndFormat(hal.getMemory().getTotal())+"Mb", true)
|
||||
.addField("JVM", convertAndFormat(rt.totalMemory()-rt.freeMemory())+"Mb/"+ convertAndFormat(rt.totalMemory()) +"Mb", true)
|
||||
.addField("Swap", convertAndFormat(hal.getMemory().getSwapUsed()) + "Mb/"+ convertAndFormat(hal.getMemory().getSwapTotal()) +"Mb", true)
|
||||
.addBlankField(false)
|
||||
.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)
|
||||
.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)
|
||||
.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.utils.Utils;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class Roll extends Command {
|
||||
static Random r = new Random();
|
||||
@@ -15,7 +15,7 @@ public class Roll extends Command {
|
||||
SetUsage("[NombreDés]d[NombreFaces] OU [NombreFaces]");
|
||||
}
|
||||
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if (e.getMessage().getContentRaw().split(" ").length != 1)
|
||||
{
|
||||
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.utils.MessageType;
|
||||
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 java.util.Arrays;
|
||||
@@ -17,14 +17,14 @@ public class FLoad extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||
String args = StringUtils.join(Arrays.copyOfRange(e.getMessage().getContentRaw().split(" "), 1, e.getMessage().getContentRaw().split(" ").length), " ");
|
||||
|
||||
e.getGuild().getAudioManager().openAudioConnection(e.getMember().getVoiceState().getChannel());
|
||||
//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);
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@ package fr.Skydust.JdrBot.cmds.playmusic;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -17,7 +17,7 @@ public class FLoadLoop extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(e.getMember().getVoiceState().getChannel() != null) {
|
||||
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?)://.*")) {
|
||||
args = "ytsearch:"+args;
|
||||
}
|
||||
PlayMusic.loadAndPlay(e.getChannel(), StringUtils.join(args," "), true, false);
|
||||
PlayMusic.loadAndPlay(e.getGuild(), e.getChannel(), StringUtils.join(args," "), true, false);
|
||||
} else {
|
||||
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.Map;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack;
|
||||
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.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler;
|
||||
import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager;
|
||||
@@ -37,7 +36,7 @@ public class PlayMusic extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(!e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
return;
|
||||
}
|
||||
@@ -47,7 +46,7 @@ public class PlayMusic extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!e.getMember().getVoiceState().inVoiceChannel()) {
|
||||
if(!e.getMember().getVoiceState().inAudioChannel()) {
|
||||
e.getChannel().sendMessage("/!\\ Vous devez être dans un channel vocal").queue();
|
||||
return;
|
||||
}
|
||||
@@ -65,10 +64,10 @@ public class PlayMusic extends Command {
|
||||
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);
|
||||
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
|
||||
GuildMusicManager musicManager = getGuildAudioPlayer(guild);
|
||||
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
|
||||
@Override
|
||||
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.events.guild.voice.GuildVoiceLeaveEvent;
|
||||
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class StopMusic extends Command {
|
||||
public StopMusic() {
|
||||
@@ -16,7 +16,7 @@ public class StopMusic extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
if(!e.getGuild().getAudioManager().isConnected() || !e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import fr.Skydust.JdrBot.stock.Command;
|
||||
import fr.Skydust.JdrBot.stock.RecordState;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class CancelRecord extends Command {
|
||||
public CancelRecord() {
|
||||
@@ -14,7 +14,7 @@ public class CancelRecord extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||
if(rs.isRecording) {
|
||||
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||
|
||||
@@ -3,7 +3,6 @@ package fr.Skydust.JdrBot.cmds.record;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import fr.Skydust.JdrBot.audio.GuildMusicManager;
|
||||
import fr.Skydust.JdrBot.audio.handler.JdrBotARH;
|
||||
import fr.Skydust.JdrBot.stock.RecordState;
|
||||
import fr.Skydust.JdrBot.stock.Command;
|
||||
@@ -11,7 +10,7 @@ import fr.Skydust.JdrBot.utils.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.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
|
||||
public class Record extends Command {
|
||||
public static HashMap<Long, RecordState> recordStates = new HashMap<>();
|
||||
@@ -22,7 +21,7 @@ public class Record extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e)
|
||||
public void call(MessageReceivedEvent e)
|
||||
{
|
||||
if(e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
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.utils.MessageType;
|
||||
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 StopRecord() {
|
||||
@@ -14,7 +14,7 @@ public class StopRecord extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(GuildMessageReceivedEvent e) {
|
||||
public void call(MessageReceivedEvent e) {
|
||||
RecordState rs = Record.getGuildRecordState(e.getGuild());
|
||||
if(rs.isRecording) {
|
||||
if(PlayMusic.getGuildsJukebox(e.getGuild()) == null) {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class JukeboxSystem {
|
||||
|
||||
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
|
||||
songPlayedPath = currentFolder + "/" + itemId;
|
||||
|
||||
@@ -36,7 +36,7 @@ public class Menu {
|
||||
|
||||
return new MessageBuilder()
|
||||
.append(name)
|
||||
.setEmbed(
|
||||
.setEmbeds(
|
||||
new EmbedBuilder()
|
||||
.setThumbnail(thumbnail)
|
||||
.setTitle(title,null)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
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 String cmdName;
|
||||
@@ -8,7 +8,7 @@ public abstract class Command {
|
||||
public String cmdUsage = "";
|
||||
public boolean hidden = false;
|
||||
|
||||
public abstract void call(GuildMessageReceivedEvent e);
|
||||
public abstract void call(MessageReceivedEvent e);
|
||||
|
||||
public void Hide() {
|
||||
hidden = true;
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.List;
|
||||
import fr.Skydust.JdrBot.utils.MessageType;
|
||||
import fr.Skydust.JdrBot.utils.Utils;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.MessageChannel;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.lingala.zip4j.ZipFile;
|
||||
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;
|
||||
isProcessing = true;
|
||||
|
||||
@@ -85,7 +86,7 @@ public class RecordState {
|
||||
}).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
|
||||
String OriginalName = new Date().toString().replaceAll(":", "-");
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ package fr.Skydust.JdrBot.utils;
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class HeartbeatTask extends TimerTask {
|
||||
@@ -19,7 +22,14 @@ public class HeartbeatTask extends TimerTask {
|
||||
long ping = JdrBot.jda.getGatewayPing();
|
||||
|
||||
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) {
|
||||
System.out.println("Error: "+e.getMessage());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.Skydust.JdrBot.utils;
|
||||
import fr.Skydust.JdrBot.JdrBot;
|
||||
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 java.awt.*;
|
||||
@@ -53,7 +54,7 @@ public class Utils {
|
||||
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;
|
||||
String title = "Message";
|
||||
|
||||
@@ -62,7 +63,7 @@ public class Utils {
|
||||
title = "Erreur";
|
||||
}
|
||||
|
||||
channel.sendMessage(new MessageBuilder().setEmbed(new EmbedBuilder().
|
||||
channel.sendMessage(new MessageBuilder().setEmbeds(new EmbedBuilder().
|
||||
setDescription(message)
|
||||
.setTitle(title, null)
|
||||
.setFooter("", JdrBot.jda.getSelfUser().getAvatarUrl())
|
||||
|
||||
Reference in New Issue
Block a user