Added GetArg(name) to CommandEventArgs
This commit is contained in:
@@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -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 }
|
||||||
|
|||||||
@@ -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);
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user