From 8ce41f88f8eed5a1be17f9871b532265dc6a9d11 Mon Sep 17 00:00:00 2001 From: Unknown Date: Thu, 9 Nov 2017 11:09:54 +0100 Subject: [PATCH] Adding permanant help message, updating JDA --- pom.xml | 8 ++++++- src/main/java/net/Broken/Commandes/Flush.java | 1 - src/main/java/net/Broken/Commandes/Help.java | 23 ++++++++++++++----- src/main/java/net/Broken/audio/AudioM.java | 8 +++++++ 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/pom.xml b/pom.xml index 129e67d..bfad96c 100644 --- a/pom.xml +++ b/pom.xml @@ -52,7 +52,13 @@ net.dv8tion JDA - 3.3.0_260 + + 3.3.1_303 + + + org.apache.logging.log4j + log4j-slf4j-impl + 2.9.1 diff --git a/src/main/java/net/Broken/Commandes/Flush.java b/src/main/java/net/Broken/Commandes/Flush.java index cac7e4d..1744ccd 100644 --- a/src/main/java/net/Broken/Commandes/Flush.java +++ b/src/main/java/net/Broken/Commandes/Flush.java @@ -33,7 +33,6 @@ public class Flush implements Commande{ int limit = Integer.parseInt(args[0]); MessageChannel chanel = event.getChannel(); MessageHistory history = chanel.getHistoryAround(chanel.getLatestMessageIdLong(), 100).complete(); - logger.debug(history.getRetrievedHistory().size()); List retrieved = history.getRetrievedHistory(); if(limit > retrieved.size()) limit = retrieved.size()-1; diff --git a/src/main/java/net/Broken/Commandes/Help.java b/src/main/java/net/Broken/Commandes/Help.java index c03c9fa..3a7a66e 100644 --- a/src/main/java/net/Broken/Commandes/Help.java +++ b/src/main/java/net/Broken/Commandes/Help.java @@ -39,11 +39,22 @@ public class Help implements Commande { logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName()); if(!event.isFromType(ChannelType.PRIVATE)) { Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getHelp(argsString, MainBot.commandes.get(argsString).help(args))).complete(); - List messages = new ArrayList(){{ - add(rest); - add(event.getMessage()); - }}; - new MessageTimeOut(messages,MainBot.messageTimeOut).start(); + if(args.length<=1) + { + List messages = new ArrayList(){{ + add(rest); + add(event.getMessage()); + }}; + new MessageTimeOut(messages,MainBot.messageTimeOut).start(); + } + else if(!args[1].toLowerCase().equals("true")){ + List messages = new ArrayList(){{ + add(rest); + add(event.getMessage()); + }}; + new MessageTimeOut(messages,MainBot.messageTimeOut).start(); + } + } else{ PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getHelp(argsString, MainBot.commandes.get(argsString).help(args)),logger); } @@ -81,7 +92,7 @@ public class Help implements Commande { new MessageTimeOut(messages,MainBot.messageTimeOut).start(); } - PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Commandes du bot").setDescription(txt.toString()).setFooter("Utilise '//help ' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger); + PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Commandes du bot").setDescription(txt.toString()).setFooter("Utilise '//help ' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger); diff --git a/src/main/java/net/Broken/audio/AudioM.java b/src/main/java/net/Broken/audio/AudioM.java index abf56fb..ed42297 100644 --- a/src/main/java/net/Broken/audio/AudioM.java +++ b/src/main/java/net/Broken/audio/AudioM.java @@ -18,6 +18,8 @@ import net.dv8tion.jda.core.entities.VoiceChannel; import net.dv8tion.jda.core.events.guild.voice.GuildVoiceLeaveEvent; import net.dv8tion.jda.core.events.message.MessageReceivedEvent; import net.dv8tion.jda.core.managers.AudioManager; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import java.util.ArrayList; import java.util.List; @@ -28,6 +30,7 @@ public class AudioM { private VoiceChannel playedChanel; private int listTimeOut = 30; private int listExtremLimit = 300; + private Logger logger = LogManager.getLogger(); public AudioM() { this.playerManager = new DefaultAudioPlayerManager(); @@ -42,6 +45,7 @@ public class AudioM { playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() { @Override public void trackLoaded(AudioTrack track) { + logger.info("Single Track detected!"); Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Ajout de "+track.getInfo().title+" à la file d'attente!")).complete(); List messages = new ArrayList(){{ add(message); @@ -53,6 +57,7 @@ public class AudioM { @Override public void playlistLoaded(AudioPlaylist playlist) { + logger.info("Playlist detected! Limit: "+playlistLimit); AudioTrack firstTrack = playlist.getSelectedTrack(); Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicOk("Ajout de "+firstTrack.getInfo().title+" et les 30 premiers titres à la file d'attente!")).complete(); @@ -73,6 +78,7 @@ public class AudioM { @Override public void noMatches() { + logger.warn("Cant find media!"); Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Musique introuvable!")).complete(); List messages = new ArrayList(){{ add(message); @@ -83,6 +89,8 @@ public class AudioM { @Override public void loadFailed(FriendlyException exception) { + logger.error("Cant load media!"); + logger.error(exception.getMessage()); Message message = event.getTextChannel().sendMessage(EmbedMessageUtils.getMusicError("Erreur de lecture!")).complete(); List messages = new ArrayList(){{ add(message);