Added support for custom errors from permission checkers

This commit is contained in:
RogueException
2015-11-10 15:37:32 -04:00
parent d9759abf4c
commit f06a1d7278
8 changed files with 52 additions and 27 deletions

View File

@@ -106,25 +106,26 @@ namespace Discord.Commands
_commands.Add(command);
}
public bool CanRun(User user, Channel channel)
public bool CanRun(User user, Channel channel, out string error)
{
if (_commands.Count > 0)
{
foreach (var cmd in _commands)
{
if (cmd.CanRun(user, channel))
return true;
if (!cmd.CanRun(user, channel, out error))
return false;
}
}
if (_items.Count > 0)
{
foreach (var item in _items)
{
if (item.Value.CanRun(user, channel))
return true;
if (!item.Value.CanRun(user, channel, out error))
return false;
}
}
return false;
error = null;
return true;
}
}
}