【发布时间】:2017-06-25 22:59:13
【问题描述】:
我想教我的 DiscordBot 在编写命令后如何处理输入。
我以这种方式创建命令:
private void CreateCommand(string commandName, string parameterName, ParameterType parameterType , string commandValue) // Register this command by the name and the answer value
{
commands.CreateCommand(commandName).Parameter(parameterName, parameterType).Do(async (e) =>
{
await e.Channel.SendMessage(commandValue); // Bots answer
});
}
我用这个方法来缩短我的下一个方法的代码:
private void Add(string commandName, string commandValue, string commandDescription) // Add a simple command to the List
{
singleCommandList.Add(new Tuple<string, string, string>(commandName, commandValue, commandDescription));
}
private void Add(string commandName, string parameterName, ParameterType parameterType, string commandValue, string commandDescription) // Add commands with Parameters to the List
{
parameterCommandList.Add(new Tuple<string, string, ParameterType, string, string>(commandName, parameterName, parameterType, commandValue, commandDescription));
}
这是填充我的 CommandList 的方法
private void FillCommandList() // Add all the commands to the List
{
Add("test", "success", "test"); // simple Command
Add("search", "onlineSearch", ParameterType.Multiple, Search("text to look for"), "Google it");
}
我的问题是我不知道如何填写方法Search()的参数。我必须在那里传递什么? e.User ..?
【问题讨论】: