|
@@ -9,8 +9,6 @@ namespace Discord.Commands |
|
|
/// <summary> A Discord.Net client with extensions for handling common bot operations like text commands. </summary> |
|
|
/// <summary> A Discord.Net client with extensions for handling common bot operations like text commands. </summary> |
|
|
public sealed partial class CommandService : IService |
|
|
public sealed partial class CommandService : IService |
|
|
{ |
|
|
{ |
|
|
private const string DefaultPermissionError = "You do not have permission to access this command."; |
|
|
|
|
|
|
|
|
|
|
|
private readonly CommandServiceConfig _config; |
|
|
private readonly CommandServiceConfig _config; |
|
|
private readonly CommandGroupBuilder _root; |
|
|
private readonly CommandGroupBuilder _root; |
|
|
private DiscordClient _client; |
|
|
private DiscordClient _client; |
|
@@ -117,7 +115,7 @@ namespace Discord.Commands |
|
|
string errorText; |
|
|
string errorText; |
|
|
if (!command.CanRun(eventArgs.User, eventArgs.Channel, out errorText)) |
|
|
if (!command.CanRun(eventArgs.User, eventArgs.Channel, out errorText)) |
|
|
{ |
|
|
{ |
|
|
RaiseCommandError(CommandErrorType.BadPermissions, eventArgs, new Exception(errorText ?? DefaultPermissionError)); |
|
|
|
|
|
|
|
|
RaiseCommandError(CommandErrorType.BadPermissions, eventArgs, errorText != null ? new Exception(errorText) : null); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -262,7 +260,7 @@ namespace Discord.Commands |
|
|
StringBuilder output = new StringBuilder(); |
|
|
StringBuilder output = new StringBuilder(); |
|
|
string error; |
|
|
string error; |
|
|
if (!command.CanRun(user, channel, out error)) |
|
|
if (!command.CanRun(user, channel, out error)) |
|
|
output.AppendLine(error ?? DefaultPermissionError); |
|
|
|
|
|
|
|
|
output.AppendLine(error ?? "You do not have permission to access this command."); |
|
|
else |
|
|
else |
|
|
ShowCommandHelpInternal(command, user, channel, output); |
|
|
ShowCommandHelpInternal(command, user, channel, output); |
|
|
return (replyChannel ?? channel).SendMessage(output.ToString()); |
|
|
return (replyChannel ?? channel).SendMessage(output.ToString()); |
|
|