Show only usable command on help #10
This commit is contained in:
parent
aa392d8cf2
commit
44ddf2b24e
@ -2,10 +2,12 @@ package net.Broken.Commands;
|
||||
|
||||
import net.Broken.Commande;
|
||||
import net.Broken.MainBot;
|
||||
import net.Broken.RestApi.CommandInterface;
|
||||
import net.Broken.Tools.EmbedMessageUtils;
|
||||
import net.Broken.Tools.MessageTimeOut;
|
||||
import net.Broken.Tools.PrivateMessage;
|
||||
import net.dv8tion.jda.core.EmbedBuilder;
|
||||
import net.dv8tion.jda.core.Permission;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Message;
|
||||
import net.dv8tion.jda.core.entities.MessageEmbed;
|
||||
@ -36,6 +38,9 @@ public class Help implements Commande {
|
||||
String argsString = args[0];
|
||||
//System.out.println(argsString);
|
||||
if (MainBot.commandes.containsKey(argsString))
|
||||
{
|
||||
Commande cmdObj = MainBot.commandes.get(argsString);
|
||||
if(!cmdObj.isAdminCmd() || event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
||||
{
|
||||
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
|
||||
MessageEmbed messageEmbed;
|
||||
@ -72,6 +77,23 @@ public class Help implements Commande {
|
||||
} else{
|
||||
PrivateMessage.send(event.getAuthor(), messageEmbed,logger);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.info("Help wanted for admin command, Denied!");
|
||||
if(!event.isFromType(ChannelType.PRIVATE)) {
|
||||
Message rest = event.getTextChannel().sendMessage(EmbedMessageUtils.getUnautorized()).complete();
|
||||
List<Message> messages = new ArrayList<Message>(){{
|
||||
add(rest);
|
||||
add(event.getMessage());
|
||||
}};
|
||||
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
|
||||
|
||||
} else{
|
||||
PrivateMessage.send(event.getAuthor(), EmbedMessageUtils.getUnautorized(), logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -94,6 +116,7 @@ public class Help implements Commande {
|
||||
{
|
||||
StringBuilder txt= new StringBuilder();
|
||||
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
|
||||
if(!e.getValue().isAdminCmd() || event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
||||
txt.append("\n- ").append(e.getKey());
|
||||
}
|
||||
|
||||
@ -106,7 +129,14 @@ public class Help implements Commande {
|
||||
new MessageTimeOut(messages,MainBot.messageTimeOut).start();
|
||||
}
|
||||
|
||||
PrivateMessage.send(event.getAuthor(),new EmbedBuilder().setTitle("Command 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);
|
||||
|
||||
String role;
|
||||
if(event.getMember().hasPermission(Permission.ADMINISTRATOR))
|
||||
role = "Admin";
|
||||
else
|
||||
role = "Non Admin";
|
||||
|
||||
PrivateMessage.send(event.getAuthor(),EmbedMessageUtils.getHelpList(role, txt.toString()),logger);
|
||||
|
||||
|
||||
|
||||
|
@ -98,5 +98,9 @@ public class EmbedMessageUtils {
|
||||
return getError("Vous n'avez pas l'autorisation de faire ça!");
|
||||
}
|
||||
|
||||
public static MessageEmbed getHelpList(String role, String list){
|
||||
return new EmbedBuilder().setTitle("Command du bot ("+role+")").setDescription(list).setFooter("Utilise '//help <commande>' pour plus de détails.",null).setColor(Color.green).setThumbnail(MainBot.jda.getSelfUser().getAvatarUrl()).build();
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user