From 9344c1b498462dc9378a879df9617bcae16e12ac Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Thu, 2 Mar 2017 03:41:33 -0500 Subject: [PATCH] Support for embeds in .qsearch output - Support for embeds in .qsearch output results - Search can be case insensitive (changes made 011b951a29d7a1754ad8e058bc2c092c78c281e3) - Output shows keyword in lowercase as it's easier to read (line 104) - Minor syntax cleanups --- .../Modules/Utility/Commands/QuoteCommands.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 5a7fc983..2b5a927d 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -72,8 +72,8 @@ namespace NadekoBot.Modules.Utility await Context.Channel.SendMessageAsync("📣 " + quote.Text.SanitizeMentions()); } - [NadekoCommand, Usage, Description, Aliases] - [RequireContext(ContextType.Guild)] + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] public async Task SearchQuote(string keyword, [Remainder] string text) { if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) @@ -83,14 +83,25 @@ namespace NadekoBot.Modules.Utility Quote keywordquote; using (var uow = DbHandler.UnitOfWork()) - { + { keywordquote = await uow.Quotes.SearchQuoteKeywordTextAsync(Context.Guild.Id, keyword, text).ConfigureAwait(false); - } + } if (keywordquote == null) return; - - await Context.Channel.SendMessageAsync("💬 " + keyword + ": " + keywordquote.Text.SanitizeMentions()); + + CREmbed crembed; + if (CREmbed.TryParse(keywordquote.Text, out crembed)) + { + try { await Context.Channel.EmbedAsync(crembed.ToEmbed(), crembed.PlainText ?? "").ConfigureAwait(false); } + catch (Exception ex) + { + _log.Warn("Sending CREmbed failed"); + _log.Warn(ex); + } + return; + } + await Context.Channel.SendMessageAsync("💬 " + keyword.toLowerInvariant(); + ": " + keywordquote.Text.SanitizeMentions()); } [NadekoCommand, Usage, Description, Aliases]