From 4ed29ea38e4c9e45e27c02b901a862aa0b7cd919 Mon Sep 17 00:00:00 2001 From: appelemac Date: Sat, 18 Jun 2016 13:26:31 +0200 Subject: [PATCH] made it a one-liner --- NadekoBot/Modules/CustomReactions/CustomReactions.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/NadekoBot/Modules/CustomReactions/CustomReactions.cs b/NadekoBot/Modules/CustomReactions/CustomReactions.cs index 4eee432a..f4ebceac 100644 --- a/NadekoBot/Modules/CustomReactions/CustomReactions.cs +++ b/NadekoBot/Modules/CustomReactions/CustomReactions.cs @@ -1,5 +1,6 @@ using Discord.Commands; using Discord.Modules; +using NadekoBot.Extensions; using NadekoBot.Modules.Permissions.Classes; using System; using System.Collections.Generic; @@ -30,6 +31,7 @@ namespace NadekoBot.Modules.CustomReactions {new Regex("%mention%"), (e,m) => NadekoBot.BotMention }, {new Regex("%user%"), (e,m) => e.User.Mention }, {new Regex("%target%"), (e,m) => e.GetArg("args")?.Trim() ?? "" }, + }; } @@ -51,13 +53,8 @@ namespace NadekoBot.Modules.CustomReactions .Do(async e => { string str = command.Value[rng.Next(0, command.Value.Count())]; - foreach (var key in commandFuncs.Keys) - { - foreach (Match m in key.Matches(str)) - { - str = str.Replace(m.Value, commandFuncs[key](e, m)); - } - } + commandFuncs.Keys.ForEach(key => str = key.Replace(str, m => commandFuncs[key](e, m))); + await e.Channel.SendMessage(str).ConfigureAwait(false); });