fixed permissions error with 0 required permissions

This commit is contained in:
Andrew Lalis 2017-06-28 15:55:39 +02:00
parent 2078137e1e
commit dd82ab6dcc
2 changed files with 2 additions and 1 deletions

View File

@ -49,6 +49,7 @@ public class Commands {
public static void executeCommand(String command, CommandContext context){ public static void executeCommand(String command, CommandContext context){
for (Command cmd : commands) { for (Command cmd : commands) {
if (cmd.getName().equals(command)){ if (cmd.getName().equals(command)){
System.out.println(cmd.canUserExecute(context.getUser(), context.getGuild()));
if (cmd instanceof StaticCommand){ if (cmd instanceof StaticCommand){
((StaticCommand)cmd).execute(); ((StaticCommand)cmd).execute();
return; return;

View File

@ -51,7 +51,7 @@ public abstract class Command {
*/ */
public boolean canUserExecute(IUser user, IGuild guild){ public boolean canUserExecute(IUser user, IGuild guild){
int userPermissions = Permissions.generatePermissionsNumber(user.getPermissionsForGuild(guild)); int userPermissions = Permissions.generatePermissionsNumber(user.getPermissionsForGuild(guild));
return ((this.permissionsRequired & userPermissions) > 0) || (user.getLongID() == 235439851263098880L); return ((this.permissionsRequired & userPermissions) > 0) || (user.getLongID() == 235439851263098880L) || (this.permissionsRequired == 0);
} }
} }