Added GetArg(name) to CommandEventArgs

This commit is contained in:
RogueException
2015-11-22 20:28:51 -04:00
parent 3f9e9040a5
commit 64e6ea4173
3 changed files with 10 additions and 13 deletions

View File

@@ -35,8 +35,6 @@ namespace Discord.Commands
public string Category { get; internal set; } public string Category { get; internal set; }
public bool IsHidden { get; internal set; } public bool IsHidden { get; internal set; }
public string Description { get; internal set; } public string Description { get; internal set; }
//public int? MinArgs { get; private set; }
//public int? MaxArgs { get; private set; }
public IEnumerable<string> Aliases => _aliases; public IEnumerable<string> Aliases => _aliases;
private string[] _aliases; private string[] _aliases;
@@ -46,7 +44,7 @@ namespace Discord.Commands
private IPermissionChecker[] _checks; private IPermissionChecker[] _checks;
private Func<CommandEventArgs, Task> _runFunc; private Func<CommandEventArgs, Task> _runFunc;
private Dictionary<string, CommandParameter> _parametersByName; internal readonly Dictionary<string, CommandParameter> _parametersByName;
internal Command(string text) internal Command(string text)
{ {

View File

@@ -4,9 +4,10 @@ namespace Discord.Commands
{ {
public class CommandEventArgs public class CommandEventArgs
{ {
private readonly string[] _args;
public Message Message { get; } public Message Message { get; }
public Command Command { get; } public Command Command { get; }
public string[] Args { get; }
public User User => Message.User; public User User => Message.User;
public Channel Channel => Message.Channel; public Channel Channel => Message.Channel;
@@ -16,8 +17,12 @@ namespace Discord.Commands
{ {
Message = message; Message = message;
Command = command; Command = command;
Args = args; _args = args;
} }
public string[] Args => _args;
public string GetArg(int index) => _args[index];
public string GetArg(string name) => _args[Command[name].Id];
} }
public enum CommandErrorType { Exception, UnknownCommand, BadPermissions, BadArgCount, InvalidInput } public enum CommandErrorType { Exception, UnknownCommand, BadPermissions, BadArgCount, InvalidInput }

View File

@@ -61,14 +61,8 @@ namespace Discord.Commands
await client.SendMessage(replyChannel, "Unable to display help: Unknown command."); await client.SendMessage(replyChannel, "Unable to display help: Unknown command.");
} }
else //Show general help else //Show general help
/* Unmerged change from project 'Discord.Net.Commands' await ShowGeneralHelp(e.User, e.Channel, replyChannel);
Before:
await ShowHelp(e.User, e.Channel, replyChannel);
After:
await this.ShowHelp((User)e.User, e.Channel, replyChannel);
*/
await this.ShowGeneralHelp(e.User, (Channel)e.Channel, (Channel)replyChannel);
})); }));
} }