C#和#x2B;Discord.NET-命令是否包含字符串?

C#和#x2B;Discord.NET-命令是否包含字符串?,c#,string,command,message,discord.net,C#,String,Command,Message,Discord.net,因此,我想创建一个命令,其中用户在命令中键入其他内容,并由此定义一个字符串。该字符串稍后用于将用户重定向到网站 意思是: //The string is defined here by user (string = what user typed in after "command") (how?) commands.CreateCommand("command", string add_link) .Do(async (e) => { /

因此,我想创建一个命令,其中用户在命令中键入其他内容,并由此定义一个字符串。该字符串稍后用于将用户重定向到网站

意思是:

//The string is defined here by user (string = what user typed in after "command") (how?)
commands.CreateCommand("command", string add_link)

            .Do(async (e) =>
            {
//String is added to website.
                await e.Channel.SendMessage("www.website.com/" + add_link);
            });

这可能吗?

非常简单,只需添加对.Parameter()的调用来定义它,然后使用GetArgs()检索它。请参见此示例:

 cmd.CreateCommand("linkit")                
 .Parameter("url", ParameterType.Unparsed)
 .Do(async e =>
 {
     string msg = e.GetArg("url");                        
     await e.Channel.SendMessage("the text is: "+msg);
 });
这将像这样使用(假设您的机器人的密钥是“!”):


根据此示例Bot改编的示例:

因此,用户键入“command thingamabob”,而您希望将“thingamabob”本身作为字符串获取?@JamesCurran是的,我想要的正是它。@ThePebbleStealer没有问题。我在答案中添加了到示例bot的链接,它演示了大部分Discord.NETAPI
[fhl] !linkit foobar
[bot] the text is: foobar