Browse Source

Fixed some permissions issues in the built-in help.

tags/docs-0.9
RogueException 9 years ago
parent
commit
bdf89c91c4
2 changed files with 12 additions and 12 deletions
  1. +6
    -6
      src/Discord.Net.Commands/CommandMap.cs
  2. +6
    -6
      src/Discord.Net.Commands/CommandService.cs

+ 6
- 6
src/Discord.Net.Commands/CommandMap.cs View File

@@ -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))
return false;
if (cmd.CanRun(user, channel, out error))
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))
return false;
if (item.Value.CanRun(user, channel, out error))
return true;
} }
} }
error = null;
return true;
return false;
} }
} }
} }

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

@@ -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($": {command.Description ?? "No description set for this command."}");
output.AppendLine("`");
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) + '`');


Loading…
Cancel
Save