Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 不一致:command参数中的撇号在C中不起作用_C#_Bots_Discord_Discord.net - Fatal编程技术网

C# 不一致:command参数中的撇号在C中不起作用

C# 不一致:command参数中的撇号在C中不起作用,c#,bots,discord,discord.net,C#,Bots,Discord,Discord.net,我在处理命令的参数时遇到问题。在争论中出现撇号“之前,它们工作得很好。在这种情况下,什么也不会发生。Bot什么都不做,应用程序不会崩溃。当我尝试调试该命令时,我发现它甚至不会转到它的代码分支 例如: !!我的作品很好 但是!埃科,我很好 我的代码: client.UsingCommands(input => { input.PrefixChar = '!'; input.AllowMentionPrefix = true; }); command = client.GetSer

我在处理命令的参数时遇到问题。在争论中出现撇号“之前,它们工作得很好。在这种情况下,什么也不会发生。Bot什么都不做,应用程序不会崩溃。当我尝试调试该命令时,我发现它甚至不会转到它的代码分支

例如:

!!我的作品很好

但是!埃科,我很好

我的代码:

client.UsingCommands(input => { 
  input.PrefixChar = '!';
  input.AllowMentionPrefix = true;
});

command = client.GetService<CommandService>();

command.CreateCommand("echo").Parameter("param", ParameterType.Multiple).Do(async (e) => {
  var channel = e.Server.FindChannels(e.Message.Channel.Name, ChannelType.Text).FirstOrDefault();
  string msg = "";
  for (int i = 0; i < e.Args.Length; i++) {
    msg += e.Args[i] + " ";
  }
  msg = msg.Remove(msg.Length - 1);
  await channel.SendMessage(msg);
});
知道发生了什么以及为什么吗?

试试这个:

command.CreateCommand("echo")
               .Description("returns commands")
               .Parameter("message", ParameterType.Unparsed)
               .Do(async (e) =>
               {
                   Message[] messageToDelete;
                   int deleteNumber = 1;
                   messageToDelete = await e.Channel.DownloadMessages(deleteNumber);
                   await e.Channel.DeleteMessages(messageToDelete);

                   var toReturn = $":envelope: | {e.GetArg("message")}";
                   await e.Channel.SendMessage(toReturn);
                   Console.WriteLine(toReturn);
               });