Adding permanant help message, updating JDA

This commit is contained in:
Unknown 2017-11-09 11:09:54 +01:00
parent 9a5507fc1b
commit 8ce41f88f8
4 changed files with 32 additions and 8 deletions

View File

@ -52,7 +52,13 @@
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.3.0_260</version>
<!--<version>3.3.0_260</version>-->
<version>3.3.1_303</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.9.1</version>
</dependency>
</dependencies>

View File

@ -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<Message> retrieved = history.getRetrievedHistory();
if(limit > retrieved.size())
limit = retrieved.size()-1;

View File

@ -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<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
if(args.length<=1)
{
List<Message> messages = new ArrayList<Message>(){{
add(rest);
add(event.getMessage());
}};
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
}
else if(!args[1].toLowerCase().equals("true")){
List<Message> messages = new ArrayList<Message>(){{
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 <commande>' 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 <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).build(),logger);

View File

@ -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<Message> messages = new ArrayList<Message>(){{
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<Message> messages = new ArrayList<Message>(){{
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<Message> messages = new ArrayList<Message>(){{
add(message);