Fix indentation

This commit is contained in:
Finite Reality
2016-08-02 17:54:52 +01:00
parent 772fd97080
commit eb38bdd437
4 changed files with 28 additions and 28 deletions

View File

@@ -7,6 +7,6 @@ namespace Discord.Commands
{ {
public abstract class FilterAttribute : Attribute public abstract class FilterAttribute : Attribute
{ {
public abstract void OnCommandExecuting(CommandExecutionContext context); public abstract void OnCommandExecuting(CommandExecutionContext context);
} }
} }

View File

@@ -19,8 +19,8 @@ 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<FilterAttribute> Filters { get; } public IReadOnlyList<FilterAttribute> Filters { 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)
{ {
Module = module; Module = module;
@@ -38,7 +38,7 @@ namespace Discord.Commands
Synopsis = synopsis.Text; Synopsis = synopsis.Text;
Parameters = BuildParameters(methodInfo); Parameters = BuildParameters(methodInfo);
Filters = BuildFilters(methodInfo); Filters = BuildFilters(methodInfo);
_action = BuildAction(methodInfo); _action = BuildAction(methodInfo);
} }
@@ -54,13 +54,13 @@ namespace Discord.Commands
if (!parseResult.IsSuccess) if (!parseResult.IsSuccess)
return ExecuteResult.FromError(parseResult); return ExecuteResult.FromError(parseResult);
var context = new CommandExecutionContext(this, parseResult, msg); var context = new CommandExecutionContext(this, parseResult, msg);
foreach (FilterAttribute filter in Filters) foreach (FilterAttribute filter in Filters)
{ {
filter.OnCommandExecuting(context); filter.OnCommandExecuting(context);
if (context.Handled) if (context.Handled)
return ExecuteResult.FromError(CommandError.InvalidPermissions, $"Permission check for {filter.GetType().FullName} failed"); return ExecuteResult.FromError(CommandError.InvalidPermissions, $"Permission check for {filter.GetType().FullName} failed");
} }
try try
{ {
@@ -73,10 +73,10 @@ namespace Discord.Commands
} }
} }
private IReadOnlyList<FilterAttribute> BuildFilters(MethodInfo methodInfo) private IReadOnlyList<FilterAttribute> BuildFilters(MethodInfo methodInfo)
{ {
return methodInfo.GetCustomAttributes<FilterAttribute>().ToImmutableArray(); return methodInfo.GetCustomAttributes<FilterAttribute>().ToImmutableArray();
} }
private IReadOnlyList<CommandParameter> BuildParameters(MethodInfo methodInfo) private IReadOnlyList<CommandParameter> BuildParameters(MethodInfo methodInfo)
{ {
@@ -130,7 +130,7 @@ namespace Discord.Commands
{ {
if (methodInfo.ReturnType != typeof(Task)) if (methodInfo.ReturnType != typeof(Task))
throw new InvalidOperationException("Commands must return a non-generic Task."); throw new InvalidOperationException("Commands must return a non-generic Task.");
return (msg, args) => return (msg, args) =>
{ {
object[] newArgs = new object[args.Count + 1]; object[] newArgs = new object[args.Count + 1];

View File

@@ -16,6 +16,6 @@
//Execute //Execute
Exception, Exception,
InvalidPermissions InvalidPermissions
} }
} }

View File

@@ -7,19 +7,19 @@ namespace Discord.Commands
{ {
public class CommandExecutionContext public class CommandExecutionContext
{ {
public Command ExecutingCommand { get; internal set; } public Command ExecutingCommand { get; internal set; }
public ParseResult ParseResult { get; internal set; } public ParseResult ParseResult { get; internal set; }
public IMessage Message { 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) internal CommandExecutionContext(Command command, ParseResult parseResult, IMessage message)
{ {
ExecutingCommand = command; ExecutingCommand = command;
ParseResult = parseResult; ParseResult = parseResult;
Message = message; Message = message;
Handled = false; Handled = false;
} }
} }
} }