From 91a0ee31af034ed2ac74ed26c3d21fe4c2b0ad96 Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Mon, 13 Feb 2017 22:30:16 -0500 Subject: [PATCH] Add quote search by keyword and text command Quote search by keyword and text --- .../Modules/Utility/Commands/QuoteCommands.cs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 8add0707..b136b7aa 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -58,6 +58,27 @@ namespace NadekoBot.Modules.Utility await Context.Channel.SendMessageAsync("📣 " + quote.Text.SanitizeMentions()); } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task SearchQuote(string keyword, [Remainder] string text) + { + if (string.IsNullOrWhiteSpace(keyword) || string.IsNullOrWhiteSpace(text)) + return; + + keyword = keyword.ToUpperInvariant(); + + 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()); + } [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] @@ -143,4 +164,4 @@ namespace NadekoBot.Modules.Utility } } } -} \ No newline at end of file +}