First 2 basic checks

keep-around/23b8b9e8830874d5f04b57600c3660bddce1287b
Pingex aka Raphaël 9 years ago
parent 9d6ccc3344
commit 86a68de6ab

@ -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;
}
}

@ -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;
}
}