Fixed some permissions issues in the built-in help.
This commit is contained in:
@@ -114,24 +114,24 @@ namespace Discord.Commands
|
|||||||
|
|
||||||
public bool CanRun(User user, Channel channel, out string error)
|
public bool CanRun(User user, Channel channel, out string error)
|
||||||
{
|
{
|
||||||
|
error = null;
|
||||||
if (_commands.Count > 0)
|
if (_commands.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var cmd in _commands)
|
foreach (var cmd in _commands)
|
||||||
{
|
{
|
||||||
if (!cmd.CanRun(user, channel, out error))
|
if (cmd.CanRun(user, channel, out error))
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_items.Count > 0)
|
if (_items.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (var item in _items)
|
foreach (var item in _items)
|
||||||
{
|
{
|
||||||
if (!item.Value.CanRun(user, channel, out error))
|
if (item.Value.CanRun(user, channel, out error))
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
error = null;
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ namespace Discord.Commands
|
|||||||
.Parameter("command", ParameterType.Multiple)
|
.Parameter("command", ParameterType.Multiple)
|
||||||
.Hide()
|
.Hide()
|
||||||
.Description("Returns information about commands.")
|
.Description("Returns information about commands.")
|
||||||
.Do((Func<CommandEventArgs, Task>)(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
Channel replyChannel = _config.HelpMode == HelpMode.Public ? e.Channel : await client.CreatePMChannel(e.User);
|
Channel replyChannel = _config.HelpMode == HelpMode.Public ? e.Channel : await client.CreatePMChannel(e.User);
|
||||||
if (e.Args.Length > 0) //Show command help
|
if (e.Args.Length > 0) //Show command help
|
||||||
@@ -62,7 +62,7 @@ namespace Discord.Commands
|
|||||||
}
|
}
|
||||||
else //Show general help
|
else //Show general help
|
||||||
await ShowGeneralHelp(e.User, e.Channel, replyChannel);
|
await ShowGeneralHelp(e.User, e.Channel, replyChannel);
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
client.MessageReceived += async (s, e) =>
|
client.MessageReceived += async (s, e) =>
|
||||||
@@ -209,7 +209,7 @@ namespace Discord.Commands
|
|||||||
IEnumerable<Command> cmds = map.Commands;
|
IEnumerable<Command> cmds = map.Commands;
|
||||||
bool isFirstCmd = true;
|
bool isFirstCmd = true;
|
||||||
string error;
|
string error;
|
||||||
if (cmds != null)
|
if (cmds.Any())
|
||||||
{
|
{
|
||||||
foreach (var cmd in cmds)
|
foreach (var cmd in cmds)
|
||||||
{
|
{
|
||||||
@@ -233,7 +233,7 @@ namespace Discord.Commands
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool isFirstSubCmd = true;
|
bool isFirstSubCmd = true;
|
||||||
foreach (var subCmd in map.SubGroups.Where(x => x.CanRun(user, channel, out error) && !x.IsVisible))
|
foreach (var subCmd in map.SubGroups.Where(x => x.CanRun(user, channel, out error) && x.IsVisible))
|
||||||
{
|
{
|
||||||
if (isFirstSubCmd)
|
if (isFirstSubCmd)
|
||||||
{
|
{
|
||||||
@@ -289,8 +289,8 @@ namespace Discord.Commands
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
output.Append('`');
|
output.AppendLine("`");
|
||||||
output.AppendLine($": {command.Description ?? "No description set for this command."}");
|
output.AppendLine($"{command.Description ?? "No description."}");
|
||||||
|
|
||||||
if (command.Aliases.Any())
|
if (command.Aliases.Any())
|
||||||
output.AppendLine($"Aliases: `" + string.Join("`, `", command.Aliases) + '`');
|
output.AppendLine($"Aliases: `" + string.Join("`, `", command.Aliases) + '`');
|
||||||
|
|||||||
Reference in New Issue
Block a user