Fix indentation
This commit is contained in:
@@ -7,6 +7,6 @@ namespace Discord.Commands
|
||||
{
|
||||
public abstract class FilterAttribute : Attribute
|
||||
{
|
||||
public abstract void OnCommandExecuting(CommandExecutionContext context);
|
||||
public abstract void OnCommandExecuting(CommandExecutionContext context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ namespace Discord.Commands
|
||||
public string Text { get; }
|
||||
public Module Module { get; }
|
||||
public IReadOnlyList<CommandParameter> Parameters { get; }
|
||||
public IReadOnlyList<FilterAttribute> Filters { get; }
|
||||
|
||||
public IReadOnlyList<FilterAttribute> Filters { get; }
|
||||
|
||||
internal Command(Module module, object instance, CommandAttribute attribute, MethodInfo methodInfo, string groupPrefix)
|
||||
{
|
||||
Module = module;
|
||||
@@ -38,7 +38,7 @@ namespace Discord.Commands
|
||||
Synopsis = synopsis.Text;
|
||||
|
||||
Parameters = BuildParameters(methodInfo);
|
||||
Filters = BuildFilters(methodInfo);
|
||||
Filters = BuildFilters(methodInfo);
|
||||
_action = BuildAction(methodInfo);
|
||||
}
|
||||
|
||||
@@ -54,13 +54,13 @@ namespace Discord.Commands
|
||||
if (!parseResult.IsSuccess)
|
||||
return ExecuteResult.FromError(parseResult);
|
||||
|
||||
var context = new CommandExecutionContext(this, parseResult, msg);
|
||||
foreach (FilterAttribute filter in Filters)
|
||||
{
|
||||
filter.OnCommandExecuting(context);
|
||||
if (context.Handled)
|
||||
return ExecuteResult.FromError(CommandError.InvalidPermissions, $"Permission check for {filter.GetType().FullName} failed");
|
||||
}
|
||||
var context = new CommandExecutionContext(this, parseResult, msg);
|
||||
foreach (FilterAttribute filter in Filters)
|
||||
{
|
||||
filter.OnCommandExecuting(context);
|
||||
if (context.Handled)
|
||||
return ExecuteResult.FromError(CommandError.InvalidPermissions, $"Permission check for {filter.GetType().FullName} failed");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -73,10 +73,10 @@ namespace Discord.Commands
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<FilterAttribute> BuildFilters(MethodInfo methodInfo)
|
||||
{
|
||||
return methodInfo.GetCustomAttributes<FilterAttribute>().ToImmutableArray();
|
||||
}
|
||||
private IReadOnlyList<FilterAttribute> BuildFilters(MethodInfo methodInfo)
|
||||
{
|
||||
return methodInfo.GetCustomAttributes<FilterAttribute>().ToImmutableArray();
|
||||
}
|
||||
|
||||
private IReadOnlyList<CommandParameter> BuildParameters(MethodInfo methodInfo)
|
||||
{
|
||||
@@ -130,7 +130,7 @@ namespace Discord.Commands
|
||||
{
|
||||
if (methodInfo.ReturnType != typeof(Task))
|
||||
throw new InvalidOperationException("Commands must return a non-generic Task.");
|
||||
|
||||
|
||||
return (msg, args) =>
|
||||
{
|
||||
object[] newArgs = new object[args.Count + 1];
|
||||
|
||||
@@ -16,6 +16,6 @@
|
||||
|
||||
//Execute
|
||||
Exception,
|
||||
InvalidPermissions
|
||||
InvalidPermissions
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,19 @@ namespace Discord.Commands
|
||||
{
|
||||
public class CommandExecutionContext
|
||||
{
|
||||
public Command ExecutingCommand { get; internal set; }
|
||||
public ParseResult ParseResult { get; internal set; }
|
||||
public IMessage Message { get; internal set; }
|
||||
public Command ExecutingCommand { get; internal set; }
|
||||
public ParseResult ParseResult { get; internal set; }
|
||||
public IMessage Message { get; internal set; }
|
||||
|
||||
public bool Handled { get; set; }
|
||||
public bool Handled { get; set; }
|
||||
|
||||
internal CommandExecutionContext(Command command, ParseResult parseResult, IMessage message)
|
||||
{
|
||||
ExecutingCommand = command;
|
||||
ParseResult = parseResult;
|
||||
Message = message;
|
||||
internal CommandExecutionContext(Command command, ParseResult parseResult, IMessage message)
|
||||
{
|
||||
ExecutingCommand = command;
|
||||
ParseResult = parseResult;
|
||||
Message = message;
|
||||
|
||||
Handled = false;
|
||||
}
|
||||
Handled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user