diff --git a/src/Discord.Net.Commands/CommandService.cs b/src/Discord.Net.Commands/CommandService.cs index 2ce7c5517..07566c2c4 100644 --- a/src/Discord.Net.Commands/CommandService.cs +++ b/src/Discord.Net.Commands/CommandService.cs @@ -208,7 +208,14 @@ namespace Discord.Commands if (!searchResult.IsSuccess) return searchResult; - var commands = searchResult.Commands; + // TODO: this logic is for users who don't manually search/execute: should we keep it? + + IReadOnlyList commands = searchResult.Commands + .Where(x => x.CanExecute(message)).ToImmutableArray(); + + if (commands.Count == 0 && searchResult.Commands.Count > 0) + return ParseResult.FromError(CommandError.InvalidPermissions, "Invalid permissions"); + for (int i = commands.Count - 1; i >= 0; i--) { var parseResult = await commands[i].Parse(message, searchResult);