diff --git a/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs b/src/NadekoBot/Modules/Utility/Commands/QuoteCommands.cs index ea4bc674..b8819255 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) + 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); 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. /// 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 + diff --git a/src/NadekoBot/Resources/ResponseStrings.Designer.cs b/src/NadekoBot/Resources/ResponseStrings.Designer.cs index ce51f8f4..9561c996 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.. /// diff --git a/src/NadekoBot/Resources/ResponseStrings.resx b/src/NadekoBot/Resources/ResponseStrings.resx index 42a22f42..31b11e93 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 +