Browse Source

Add logic to CommandService.Execute to handle basic permissions checks

tags/1.0-rc
Finite Reality 8 years ago
parent
commit
023703c996
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      src/Discord.Net.Commands/CommandService.cs

+ 8
- 1
src/Discord.Net.Commands/CommandService.cs View File

@@ -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<Command> 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);


Loading…
Cancel
Save