minor changes

This commit is contained in:
Master Kwoth 2016-05-13 19:30:11 +02:00
parent 0c4cee6bba
commit c51d41d40f
2 changed files with 18 additions and 10 deletions

View File

@ -12,6 +12,21 @@ namespace NadekoBot.Modules.CustomReactions
{ {
public override string Prefix { get; } = ""; public override string Prefix { get; } = "";
Random rng = new Random();
private Dictionary<string, Func<CommandEventArgs, string>> commandFuncs;
public CustomReactionsModule()
{
commandFuncs = new Dictionary<string, Func<CommandEventArgs, string>>
{
{"%rng%", (e) => rng.Next().ToString()},
{"%mention%", (e) => NadekoBot.BotMention },
{"%user%", e => e.User.Mention },
{"%target%", e => e.GetArg("args")?.Trim() ?? "" },
};
}
public override void Install(ModuleManager manager) public override void Install(ModuleManager manager)
{ {
@ -19,14 +34,6 @@ namespace NadekoBot.Modules.CustomReactions
{ {
cgb.AddCheck(PermissionChecker.Instance); cgb.AddCheck(PermissionChecker.Instance);
Random range = new Random();
Dictionary<string, Func<CommandEventArgs, string>> commandFuncs = new Dictionary<string, Func<CommandEventArgs, string>>
{
{"%rng%", (e) => range.Next().ToString()},
{"%mention%", (e) => NadekoBot.BotMention },
{"%user%", e => e.User.Mention },
{"%target%", e => e.GetArg("args")?.Trim() ?? "" },
};
foreach (var command in NadekoBot.Config.CustomReactions) foreach (var command in NadekoBot.Config.CustomReactions)
{ {
@ -39,7 +46,7 @@ namespace NadekoBot.Modules.CustomReactions
.Parameter("args", ParameterType.Unparsed) .Parameter("args", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
{ {
string str = command.Value[range.Next(0, command.Value.Count())]; string str = command.Value[rng.Next(0, command.Value.Count())];
commandFuncs.Keys.ForEach(k => str = str.Replace(k, commandFuncs[k](e))); commandFuncs.Keys.ForEach(k => str = str.Replace(k, commandFuncs[k](e)));
await e.Channel.SendMessage(str).ConfigureAwait(false); await e.Channel.SendMessage(str).ConfigureAwait(false);
}); });

View File

@ -50,7 +50,8 @@ namespace NadekoBot.Modules.Gambling
}); });
cgb.CreateCommand(Prefix + "$$") cgb.CreateCommand(Prefix + "$$")
.Description(string.Format("Check how much {0}s you have.", NadekoBot.Config.CurrencyName)) .Description(string.Format("Check how much {0}s a person has. (Defaults to yourself)\n**Usage**:`{1}$$` or `{1}$$ @Someone`",
NadekoBot.Config.CurrencyName, Prefix))
.Parameter("all", ParameterType.Unparsed) .Parameter("all", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
{ {