Some improvement

This commit is contained in:
Sebastien 2018-04-29 18:42:34 +02:00
parent 20e745aec1
commit 62130b8506
3 changed files with 26 additions and 23 deletions

View File

@ -37,8 +37,10 @@ public class Help implements Commande {
//System.out.println(argsString); //System.out.println(argsString);
if (MainBot.commandes.containsKey(argsString)) if (MainBot.commandes.containsKey(argsString))
{ {
Commande cmdObj = MainBot.commandes.get(argsString); Commande cmdObj = MainBot.commandes.get(argsString);
if(!cmdObj.isAdminCmd() || event.getMember().hasPermission(Permission.ADMINISTRATOR)) if(!cmdObj.isAdminCmd() || isAdmin(event))
{ {
logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName()); logger.info("Aide demmander pour la cmd "+argsString+" par "+event.getAuthor().getName());
MessageEmbed messageEmbed; MessageEmbed messageEmbed;
@ -119,25 +121,8 @@ public class Help implements Commande {
nsfwTable.setHeader("NSFW Only\u00A0", "PU"); nsfwTable.setHeader("NSFW Only\u00A0", "PU");
List<String> noPu = new ArrayList<>(); List<String> noPu = new ArrayList<>();
boolean isAdmin;
if(event.isFromType(ChannelType.PRIVATE)){
isAdmin = false;
List<Guild> guilds = event.getAuthor().getMutualGuilds();
for(Guild iterator : guilds){
if(iterator.getMember(event.getAuthor()).hasPermission(Permission.ADMINISTRATOR)){
isAdmin = true;
break;
}
}
}
else
isAdmin = event.getMember().hasPermission(Permission.ADMINISTRATOR);
for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) { for (Map.Entry<String, Commande> e : MainBot.commandes.entrySet()) {
if(!e.getValue().isAdminCmd() || isAdmin){ if(!e.getValue().isAdminCmd() || isAdmin(event)){
if(e.getValue().isPrivateUsable()) if(e.getValue().isPrivateUsable())
table.addRow(e.getKey(), "XX"); table.addRow(e.getKey(), "XX");
else if(e.getValue().isNSFW()) else if(e.getValue().isNSFW())
@ -163,7 +148,7 @@ public class Help implements Commande {
String role; String role;
if(isAdmin) if(isAdmin(event))
role = "Admin"; role = "Admin";
else else
role = "Non Admin"; role = "Non Admin";
@ -196,4 +181,22 @@ public class Help implements Commande {
public boolean isNSFW() { public boolean isNSFW() {
return false; return false;
} }
public boolean isAdmin(MessageReceivedEvent event){
if(event.isFromType(ChannelType.PRIVATE)){
List<Guild> guilds = event.getAuthor().getMutualGuilds();
for(Guild iterator : guilds){
if(iterator.getMember(event.getAuthor()).hasPermission(Permission.ADMINISTRATOR)){
return true;
}
}
}
else
return event.getMember().hasPermission(Permission.ADMINISTRATOR);
return false;
}
} }

View File

@ -65,8 +65,8 @@ public class DayListener extends Thread {
@Override @Override
public void run() { public void run() {
while(true) while(true)
{ calendar = Calendar.getInstance(); {
logger.debug(calendar.get(GregorianCalendar.DAY_OF_MONTH)+"/"+previousDay); calendar = Calendar.getInstance();
if(calendar.get(GregorianCalendar.DAY_OF_MONTH) != previousDay) if(calendar.get(GregorianCalendar.DAY_OF_MONTH) != previousDay)
{ {
LogManager.getLogger().info("New day triggered!"); LogManager.getLogger().info("New day triggered!");

View File

@ -132,7 +132,7 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<a href="#!" id="btn_ok_guild" class="modal-action modal-close waves-effect waves-green btn-flat disabled">Ok</a> <a href="#" id="btn_ok_guild" class="modal-action modal-close waves-effect waves-green btn-flat disabled">Ok</a>
</div> </div>
</div> </div>