Browse Source

Use custom message when a non-zero Precondition Group fails.

pull/672/head
Joe4evr 8 years ago
parent
commit
b9421ef108
2 changed files with 5 additions and 8 deletions
  1. +3
    -6
      src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs
  2. +2
    -2
      src/Discord.Net.Commands/Info/CommandInfo.cs

+ 3
- 6
src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs View File

@@ -7,12 +7,9 @@ namespace Discord.Commands
public abstract class PreconditionAttribute : Attribute public abstract class PreconditionAttribute : Attribute
{ {
/// <summary> /// <summary>
/// Specify a group that this precondition belongs to.
/// Preconditions of the same group require only one
/// of the preconditions to pass in order to be
/// successful (A || B). Specifying <see cref="Group"/> = 0
/// or not at all will require *all* preconditions
/// to pass, just like normal (A && B).
/// Specify a group that this precondition belongs to. Preconditions of the same group require only one
/// of the preconditions to pass in order to be successful (A || B). Specifying <see cref="Group"/> = 0
/// or not at all will require *all* preconditions to pass, just like normal (A && B).
/// </summary> /// </summary>
public int Group { get; set; } = 0; public int Group { get; set; } = 0;




+ 2
- 2
src/Discord.Net.Commands/Info/CommandInfo.cs View File

@@ -86,7 +86,7 @@ namespace Discord.Commands
results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false)); results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false));


if (!results.Any(p => p.IsSuccess)) if (!results.Any(p => p.IsSuccess))
return results[0];
return PreconditionResult.FromError($"Module precondition group {preconditionGroup.Key} failed: {String.Join("\n", results.Select(r => r.ErrorReason))}.");
} }
} }


@@ -108,7 +108,7 @@ namespace Discord.Commands
results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false)); results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false));


if (!results.Any(p => p.IsSuccess)) if (!results.Any(p => p.IsSuccess))
return results[0];
return PreconditionResult.FromError($"Command precondition group {preconditionGroup.Key} failed: {String.Join("\n", results.Select(r => r.ErrorReason))}.");
} }
} }




Loading…
Cancel
Save