From b9421ef108837414c8ec66663e263a8c130ef37c Mon Sep 17 00:00:00 2001 From: Joe4evr Date: Mon, 5 Jun 2017 23:42:57 +0200 Subject: [PATCH] Use custom message when a non-zero Precondition Group fails. --- .../Attributes/PreconditionAttribute.cs | 9 +++------ src/Discord.Net.Commands/Info/CommandInfo.cs | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs b/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs index 38672f071..943bddb89 100644 --- a/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs +++ b/src/Discord.Net.Commands/Attributes/PreconditionAttribute.cs @@ -7,12 +7,9 @@ namespace Discord.Commands public abstract class PreconditionAttribute : Attribute { /// - /// 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 = 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 = 0 + /// or not at all will require *all* preconditions to pass, just like normal (A && B). /// public int Group { get; set; } = 0; diff --git a/src/Discord.Net.Commands/Info/CommandInfo.cs b/src/Discord.Net.Commands/Info/CommandInfo.cs index c052629e6..61357675b 100644 --- a/src/Discord.Net.Commands/Info/CommandInfo.cs +++ b/src/Discord.Net.Commands/Info/CommandInfo.cs @@ -86,7 +86,7 @@ namespace Discord.Commands results.Add(await precondition.CheckPermissions(context, this, services).ConfigureAwait(false)); 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)); 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))}."); } }