Added GetArg(name) to CommandEventArgs
This commit is contained in:
@@ -35,8 +35,6 @@ namespace Discord.Commands
|
||||
public string Category { get; internal set; }
|
||||
public bool IsHidden { 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;
|
||||
private string[] _aliases;
|
||||
@@ -46,7 +44,7 @@ namespace Discord.Commands
|
||||
|
||||
private IPermissionChecker[] _checks;
|
||||
private Func<CommandEventArgs, Task> _runFunc;
|
||||
private Dictionary<string, CommandParameter> _parametersByName;
|
||||
internal readonly Dictionary<string, CommandParameter> _parametersByName;
|
||||
|
||||
internal Command(string text)
|
||||
{
|
||||
|
||||
@@ -4,9 +4,10 @@ namespace Discord.Commands
|
||||
{
|
||||
public class CommandEventArgs
|
||||
{
|
||||
private readonly string[] _args;
|
||||
|
||||
public Message Message { get; }
|
||||
public Command Command { get; }
|
||||
public string[] Args { get; }
|
||||
|
||||
public User User => Message.User;
|
||||
public Channel Channel => Message.Channel;
|
||||
@@ -16,8 +17,12 @@ namespace Discord.Commands
|
||||
{
|
||||
Message = message;
|
||||
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 }
|
||||
|
||||
@@ -61,14 +61,8 @@ namespace Discord.Commands
|
||||
await client.SendMessage(replyChannel, "Unable to display help: Unknown command.");
|
||||
}
|
||||
else //Show general help
|
||||
|
||||
/* Unmerged change from project 'Discord.Net.Commands'
|
||||
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);
|
||||
|
||||
await ShowGeneralHelp(e.User, e.Channel, replyChannel);
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user