diff --git a/src/main/java/net/pingex/dcf/commands/audit/basic/EnabledCheck.java b/src/main/java/net/pingex/dcf/commands/audit/basic/EnabledCheck.java new file mode 100644 index 0000000..bd77abe --- /dev/null +++ b/src/main/java/net/pingex/dcf/commands/audit/basic/EnabledCheck.java @@ -0,0 +1,37 @@ +package net.pingex.dcf.commands.audit.basic; + +import net.pingex.dcf.commands.Context; +import net.pingex.dcf.commands.audit.AuditResult; +import net.pingex.dcf.commands.audit.IAuditComponentProvider; + +/** + * This component checks whether the command is enabled, or not. + */ +public class EnabledCheck implements IAuditComponentProvider +{ + @Override + public AuditResult doAudit(Context context) + { + if(context.getCommand().isEnabled()) + return new AuditResult(AuditResult.ResultCode.PASS, null); + else return new AuditResult(AuditResult.ResultCode.FAIL, "Command is not enabled."); + } + + @Override + public String name() + { + return "Enabled command check"; + } + + @Override + public String description() + { + return "Checks whether the command is enabled, or not"; + } + + @Override + public int priority() + { + return 0; + } +} diff --git a/src/main/java/net/pingex/dcf/commands/audit/basic/ScopeCheck.java b/src/main/java/net/pingex/dcf/commands/audit/basic/ScopeCheck.java new file mode 100644 index 0000000..1172b65 --- /dev/null +++ b/src/main/java/net/pingex/dcf/commands/audit/basic/ScopeCheck.java @@ -0,0 +1,37 @@ +package net.pingex.dcf.commands.audit.basic; + +import net.pingex.dcf.commands.Context; +import net.pingex.dcf.commands.audit.AuditResult; +import net.pingex.dcf.commands.audit.IAuditComponentProvider; + +/** + * This component checks whether the command is invoked in the right scope. + */ +public class ScopeCheck implements IAuditComponentProvider +{ + @Override + public AuditResult doAudit(Context context) + { + if(context.getCommand().getScope().test(context.getChannel())) + return new AuditResult(AuditResult.ResultCode.PASS, null); + else return new AuditResult(AuditResult.ResultCode.FAIL, "Cannot run this command outside of its intended scope. Valid scope is: " + context.getCommand().getScope() + "."); + } + + @Override + public String name() + { + return "Invocation scope check"; + } + + @Override + public String description() + { + return "Checks whether the command is invoked in the right scope, ie. guild chat or PM."; + } + + @Override + public int priority() + { + return -2; + } +}