명령을 작성한 후 DiscordBot이 입력을 처리하는 방법을 가르쳐야합니다.C# Discord Bot - 명령 매개 변수에서 Userinput 가져 오기
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
..와 함께 뭔가?
사실 전체 API가 변경되었습니다. – TheOnlyMrCat