Better code
This commit is contained in:
parent
187ee73224
commit
0e69b22ab1
2 changed files with 7 additions and 10 deletions
|
|
@ -9,7 +9,6 @@ import com.bbn.hadder.commands.CommandEvent;
|
||||||
import com.bbn.hadder.core.Perm;
|
import com.bbn.hadder.core.Perm;
|
||||||
import com.bbn.hadder.core.Perms;
|
import com.bbn.hadder.core.Perms;
|
||||||
import com.bbn.hadder.utils.MessageEditor;
|
import com.bbn.hadder.utils.MessageEditor;
|
||||||
import net.dv8tion.jda.api.Permission;
|
|
||||||
|
|
||||||
@Perms(Perm.MANAGE_SERVER)
|
@Perms(Perm.MANAGE_SERVER)
|
||||||
public class InviteDetectCommand implements Command {
|
public class InviteDetectCommand implements Command {
|
||||||
|
|
|
||||||
|
|
@ -35,15 +35,13 @@ public class CommandHandler {
|
||||||
|
|
||||||
CommandEvent commandEvent = new CommandEvent(event.getJDA(), event.getResponseNumber(), event.getMessage(), rethink,
|
CommandEvent commandEvent = new CommandEvent(event.getJDA(), event.getResponseNumber(), event.getMessage(), rethink,
|
||||||
config, this, helpCommand, new MessageEditor(rethink, event.getAuthor()));
|
config, this, helpCommand, new MessageEditor(rethink, event.getAuthor()));
|
||||||
if (cmd.getClass().getAnnotations().length>0) {
|
if (cmd.getClass().getAnnotations().length > 0 && !Arrays.asList(cmd.getClass().getAnnotations()).contains(Perms.class)) {
|
||||||
if (!Arrays.asList(cmd.getClass().getAnnotations()).contains(Perms.class)) {
|
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
|
||||||
for (Perm perm : cmd.getClass().getAnnotation(Perms.class).value()) {
|
if (!perm.check(commandEvent)) {
|
||||||
if (!perm.check(commandEvent)) {
|
commandEvent.getTextChannel()
|
||||||
commandEvent.getTextChannel()
|
.sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION).build())
|
||||||
.sendMessage(commandEvent.getMessageEditor().getMessage(MessageEditor.MessageType.NO_PERMISSION).build())
|
.queue();
|
||||||
.queue();
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue