@@ -19,7 +19,7 @@ namespace Discord.Commands
public string Text { get; }
public string Text { get; }
public Module Module { get; }
public Module Module { get; }
public IReadOnlyList<CommandParameter> Parameters { get; }
public IReadOnlyList<CommandParameter> Parameters { get; }
public IReadOnlyList<Permiss ionAttribute> Permissions { get; }
public IReadOnlyList<Precondit ionAttribute> Permissions { get; }
internal Command(Module module, object instance, CommandAttribute attribute, MethodInfo methodInfo, string groupPrefix)
internal Command(Module module, object instance, CommandAttribute attribute, MethodInfo methodInfo, string groupPrefix)
{
{
@@ -42,11 +42,11 @@ namespace Discord.Commands
_action = BuildAction(methodInfo);
_action = BuildAction(methodInfo);
}
}
public bool CanExecute (IMessage message)
public bool MeetsPreconditions (IMessage message)
{
{
var context = new Permissions Context(this, message);
var context = new Precondition Context(this, message);
foreach (Permiss ionAttribute permission in Permissions)
foreach (Precondit ionAttribute permission in Permissions)
{
{
permission.CheckPermissions(context);
permission.CheckPermissions(context);
if (context.Handled)
if (context.Handled)
@@ -68,8 +68,8 @@ namespace Discord.Commands
if (!parseResult.IsSuccess)
if (!parseResult.IsSuccess)
return ExecuteResult.FromError(parseResult);
return ExecuteResult.FromError(parseResult);
if (!CanExecute (msg)) // TODO: should we have to check this here, or leave it entirely to the bot dev?
return ExecuteResult.FromError(CommandError.InvalidPermissions , "Permissions check failed");
if (!MeetsPreconditions (msg)) // TODO: should we have to check this here, or leave it entirely to the bot dev?
return ExecuteResult.FromError(CommandError.UnmetPrecondition , "Permissions check failed");
try
try
{
{
@@ -82,9 +82,9 @@ namespace Discord.Commands
}
}
}
}
private IReadOnlyList<Permiss ionAttribute> BuildPermissions(MethodInfo methodInfo)
private IReadOnlyList<Precondit ionAttribute> BuildPermissions(MethodInfo methodInfo)
{
{
return methodInfo.GetCustomAttributes<Permiss ionAttribute>().ToImmutableArray();
return methodInfo.GetCustomAttributes<Precondit ionAttribute>().ToImmutableArray();
}
}
private IReadOnlyList<CommandParameter> BuildParameters(MethodInfo methodInfo)
private IReadOnlyList<CommandParameter> BuildParameters(MethodInfo methodInfo)