From d256d520e4b12c5c89d83502d7f5e10b186d241e Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:43:02 -0400 Subject: [PATCH 1/6] Add quote ID search --- .../Modules/Utility/Commands/QuoteCommands.cs | 48 ++++++++++++++++--- 1 file changed, 42 insertions(+), 6 deletions(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index ea4bc674..37fdbf07 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -1,4 +1,4 @@ -using Discord; +using Discord; using Discord.Commands; using NadekoBot.Attributes; using NadekoBot.Extensions; @@ -100,7 +100,43 @@ namespace NadekoBot.Modules.Utility await Context.Channel.SendMessageAsync($"`#{keywordquote.Id}` 💬 " + keyword.ToLowerInvariant() + ": " + keywordquote.Text.SanitizeMentions()); } - + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task QuoteId(int id) + { + if (id < 0 || id > Int32.MaxValue) + return; + + using (var uow = DbHandler.UnitOfWork()) + { + var qfromid = uow.Quotes.Get(id); + CREmbed crembed; + + if (qfromid == null) + { + await Context.Channel.SendErrorAsync(GetText("quotes_notfound")); + } + else if (CREmbed.TryParse(qfromid.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; + } + + else { await Context.Channel.SendMessageAsync($"`#{qfromid.Id}` 🗯️ " + qfromid.Keyword.ToLowerInvariant() + ": " + + qfromid.Text.SanitizeMentions()); } + } + } + [NadekoCommand, Usage, Description, Aliases] [RequireContext(ContextType.Guild)] public async Task AddQuote(string keyword, [Remainder] string text) @@ -130,8 +166,8 @@ namespace NadekoBot.Modules.Utility public async Task DeleteQuote(int id) { var isAdmin = ((IGuildUser) Context.Message.Author).GuildPermissions.Administrator; - - var sucess = false; + + var success = false; string response; using (var uow = DbHandler.UnitOfWork()) { @@ -145,11 +181,11 @@ namespace NadekoBot.Modules.Utility { uow.Quotes.Remove(q); await uow.CompleteAsync().ConfigureAwait(false); - sucess = true; + success = true; response = GetText("quote_deleted", id); } } - if (sucess) + if (success) await Context.Channel.SendConfirmAsync(response); else await Context.Channel.SendErrorAsync(response); From 80c1c141b754fc5c3fa6f4e8a367e7e32b1abf42 Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:44:15 -0400 Subject: [PATCH 2/6] Update CommandStrings.resx --- src/NadekoBot/Resources/CommandStrings.resx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index f3662ef3..cbdfc5b3 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -1151,6 +1151,15 @@ `{0}qsearch keyword text` + + + quoteid qid + + + Displays the quote with the specified ID number. Quote ID numbers can be found by typing `.liqu [num]` where `[num]` is a number of a page which contains 15 quotes. + + + `{0}qid 123456` deletequote delq @@ -3339,4 +3348,4 @@ `{0}slowmodewl SomeRole` or `{0}slowmodewl AdminDude` - \ No newline at end of file + From 44e8939a5beefdcc289a0aede312340bb7288e4a Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:46:30 -0400 Subject: [PATCH 3/6] Update CommandStrings.Designer.cs --- .../Resources/CommandStrings.Designer.cs | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index 76dac5be..437ef468 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -5729,6 +5729,33 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar quoteid qid. + /// + public static string quoteid_cmd { + get { + return ResourceManager.GetString("quoteid_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Displays the quote with the specified ID number. Quote ID numbers can be found by typing `.liqu [num]` where `[num]` is a number of a page which contains 15 quotes.. + /// + public static string quoteid_desc { + get { + return ResourceManager.GetString("quoteid_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}qid 123456`. + /// + public static string quoteid_usage { + get { + return ResourceManager.GetString("quoteid_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to race. /// From a4d78dfc0d45b49c798428521a4e358467030dc3 Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:48:17 -0400 Subject: [PATCH 4/6] Update ResponseStrings.resx --- src/NadekoBot/Resources/ResponseStrings.resx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 83d701f3..a8b2d0bb 100644 --- a/src/NadekoBot/Resources/ResponseStrings.resx +++ b/src/NadekoBot/Resources/ResponseStrings.resx @@ -2083,6 +2083,9 @@ Owner ID: {2} No quotes on this page. + + No quotes found matching the quote ID specified. + No quotes found which you can remove. @@ -2402,4 +2405,4 @@ Owner ID: {2} Rewards can be claimed on or after 5th of each month. - \ No newline at end of file + From 34b4884ec41186b52b6f4164e29f4c624b67c4b3 Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:49:43 -0400 Subject: [PATCH 5/6] Update ResponseStrings.Designer.cs --- src/NadekoBot/Resources/ResponseStrings.Designer.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index e13d8513..1aa7c15e 100644 --- a/src/NadekoBot/Resources/ResponseStrings.Designer.cs +++ b/src/NadekoBot/Resources/ResponseStrings.Designer.cs @@ -6506,6 +6506,15 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to No quotes found matching the quote ID specified.. + /// + public static string utility_quotes_notfound { + get { + return ResourceManager.GetString("utility_quotes_notfound", resourceCulture); + } + } + /// /// Looks up a localized string similar to No quotes found which you can remove.. /// From 43d8f1997a1b95bd55fb9bca03ab7cc2e620a366 Mon Sep 17 00:00:00 2001 From: Shikhir Arora Date: Sun, 2 Apr 2017 15:57:56 -0400 Subject: [PATCH 6/6] Update QuoteCommands.cs --- src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index 37fdbf07..b8819255 100644 --- a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs +++ b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs @@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Utility [RequireContext(ContextType.Guild)] public async Task QuoteId(int id) { - if (id < 0 || id > Int32.MaxValue) + if (id < 0) return; using (var uow = DbHandler.UnitOfWork())