From 7a2e547766e40c5d6dfe4f516b82e6cf020b6307 Mon Sep 17 00:00:00 2001 From: simpleauthority Date: Tue, 24 Jul 2018 18:42:54 -0700 Subject: [PATCH] Make Users optional arguments (#139) This PR allows `User`s to be optional command arguments similar to how the annotation operates on Bukkit's `Player`. --- .../main/java/co/aikar/commands/JDACommandContexts.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/jda/src/main/java/co/aikar/commands/JDACommandContexts.java b/jda/src/main/java/co/aikar/commands/JDACommandContexts.java index 1066bd2c..f109b9ab 100644 --- a/jda/src/main/java/co/aikar/commands/JDACommandContexts.java +++ b/jda/src/main/java/co/aikar/commands/JDACommandContexts.java @@ -32,7 +32,7 @@ public class JDACommandContexts extends CommandContexts jda); this.registerIssuerOnlyContext(Guild.class, c -> { MessageReceivedEvent event = c.getIssuer().getIssuer(); - if (event.isFromType(ChannelType.PRIVATE) && !c.hasAnnotation(Optional.class)) { + if (event.isFromType(ChannelType.PRIVATE) && !c.isOptional()) { throw new InvalidCommandArgument("This command can only be executed in a Guild.", false); } else { return event.getGuild(); @@ -66,7 +66,11 @@ public class JDACommandContexts extends CommandContexts