Random number and random answer

This commit is contained in:
appelemac 2016-04-26 18:27:59 +02:00
parent 0d8571509e
commit 4b521a5689

View File

@ -122,14 +122,18 @@ namespace NadekoBot.Modules.Conversations
c.Parameter("args", ParameterType.Unparsed); c.Parameter("args", ParameterType.Unparsed);
c.Do(async e => c.Do(async e =>
{ {
var str = command.Value; Random range = new Random();
var str = command.Value[range.Next(0, command.Value.Count())];
str = str.Replace("%user%", e.User.Mention); str = str.Replace("%user%", e.User.Mention);
str = str.Replace("%rng%", "" + range.Next());
if (str.Contains("%target%")) if (str.Contains("%target%"))
{ {
var args = e.GetArg("args"); var args = e.GetArg("args");
if (string.IsNullOrWhiteSpace(args)) args = string.Empty; if (string.IsNullOrWhiteSpace(args)) args = string.Empty;
str = str.Replace("%target%", e.GetArg("args")); str = str.Replace("%target%", e.GetArg("args"));
} }
await e.Channel.SendMessage(str); await e.Channel.SendMessage(str);
}); });
} }