【发布时间】:2017-06-22 13:41:50
【问题描述】:
我希望我的机器人将命令之后的整个消息作为一个整体参数。但现在情况是这样:
当我输入“!math 1 + 3”时,它只需要“1”作为参数。我希望机器人将“1 + 3”的整个字符串作为参数。
这是我的代码:
[Command("math")]
public async Task Calculate(string equation)
{
string result = new DataTable().Compute(equation, null).ToString();
//Basically to calculate from the string to find the result
if (result == "NaN")
{
await Context.Channel.SendMessageAsync("Infinity or undefined");
}
else
{
await Context.Channel.SendMessageAsync(result);
}
}
我目前正在使用 Discord.NET v1.0
【问题讨论】:
标签: c# string arguments discord discord.net