From cedf08b12882c5b8de6282824ba9c9e5f1a64f66 Mon Sep 17 00:00:00 2001 From: Master Kwoth Date: Wed, 28 Jun 2017 03:19:16 +0200 Subject: [PATCH] normal quote responses now have replacements too, not only embeds --- .../Modules/Utility/Commands/QuoteCommands.cs | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index dcdc035a..d8ea1e84 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -67,17 +67,18 @@ namespace NadekoBot.Modules.Utility if (quote == null) return; + var rep = new ReplacementBuilder() + .WithDefault(Context) + .Build(); + if (CREmbed.TryParse(quote.Text, out var crembed)) { - new ReplacementBuilder() - .WithDefault(Context) - .Build() - .Replace(crembed); + rep.Replace(crembed); await Context.Channel.EmbedAsync(crembed.ToEmbed(), crembed.PlainText?.SanitizeMentions() ?? "") .ConfigureAwait(false); return; } - await Context.Channel.SendMessageAsync($"`#{quote.Id}` 📣 " + quote.Text.SanitizeMentions()); + await Context.Channel.SendMessageAsync($"`#{quote.Id}` 📣 " + rep.Replace(quote.Text)?.SanitizeMentions()); } [NadekoCommand, Usage, Description, Aliases] @@ -115,16 +116,17 @@ namespace NadekoBot.Modules.Utility { var qfromid = uow.Quotes.Get(id); + var rep = new ReplacementBuilder() + .WithDefault(Context) + .Build(); + if (qfromid == null) { await Context.Channel.SendErrorAsync(GetText("quotes_notfound")); } else if (CREmbed.TryParse(qfromid.Text, out var crembed)) { - new ReplacementBuilder() - .WithDefault(Context) - .Build() - .Replace(crembed); + rep.Replace(crembed); await Context.Channel.EmbedAsync(crembed.ToEmbed(), crembed.PlainText?.SanitizeMentions() ?? "") .ConfigureAwait(false); @@ -132,7 +134,7 @@ namespace NadekoBot.Modules.Utility else { await Context.Channel.SendMessageAsync($"`#{qfromid.Id}` 🗯️ " + qfromid.Keyword.ToLowerInvariant().SanitizeMentions() + ": " + - qfromid.Text.SanitizeMentions()); + rep.Replace(qfromid.Text)?.SanitizeMentions()); } }