From bc4d37c0fa9073fdc7156530e01c7737592cb9c1 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Fri, 28 Oct 2016 13:14:16 +0200 Subject: [PATCH] Added >typelist and >typedel commands --- .../Games/Commands/SpeedTypingCommands.cs | 41 ++++++++++++++ .../Resources/CommandStrings.Designer.cs | 54 +++++++++++++++++++ src/NadekoBot/Resources/CommandStrings.resx | 18 +++++++ 3 files changed, 113 insertions(+) diff --git a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs index 466bc23a..801b4bab 100644 --- a/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs +++ b/src/NadekoBot/Modules/Games/Commands/SpeedTypingCommands.cs @@ -218,6 +218,47 @@ namespace NadekoBot.Modules.Games await channel.SendMessageAsync("Added new article for typing game.").ConfigureAwait(false); } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + public async Task Typelist(IUserMessage imsg, int page = 1) + { + var channel = (ITextChannel)imsg.Channel; + + if (page < 1) + return; + + var articles = TypingArticles.Skip((page - 1) * 15).Take(15); + + if (!articles.Any()) + { + await channel.SendMessageAsync($"{imsg.Author.Mention} `No articles found on that page.`").ConfigureAwait(false); + return; + } + var i = (page - 1) * 15; + await channel.SendMessageAsync(String.Join("\n", articles.Select(a => $"`#{++i}` - {a.Text.TrimTo(50)}"))) + .ConfigureAwait(false); + } + + [NadekoCommand, Usage, Description, Aliases] + [RequireContext(ContextType.Guild)] + [OwnerOnly] + public async Task Typedel(IUserMessage imsg, int index) + { + var channel = (ITextChannel)imsg.Channel; + + index -= 1; + if (index < 0 || index >= TypingArticles.Count) + return; + + var removed = TypingArticles[index]; + TypingArticles.RemoveAt(index); + + File.WriteAllText(typingArticlesPath, JsonConvert.SerializeObject(TypingArticles)); + + await channel.SendMessageAsync($"`Removed typing article:` #{index + 1} - {removed.Text.TrimTo(50)}") + .ConfigureAwait(false); + } } } } \ No newline at end of file diff --git a/src/NadekoBot/Resources/CommandStrings.Designer.cs b/src/NadekoBot/Resources/CommandStrings.Designer.cs index ef639f4c..542b2cb8 100644 --- a/src/NadekoBot/Resources/CommandStrings.Designer.cs +++ b/src/NadekoBot/Resources/CommandStrings.Designer.cs @@ -6701,6 +6701,60 @@ namespace NadekoBot.Resources { } } + /// + /// Looks up a localized string similar to typedel. + /// + public static string typedel_cmd { + get { + return ResourceManager.GetString("typedel_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Deletes a typing article given the ID.. + /// + public static string typedel_desc { + get { + return ResourceManager.GetString("typedel_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}typedel 3`. + /// + public static string typedel_usage { + get { + return ResourceManager.GetString("typedel_usage", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to typelist. + /// + public static string typelist_cmd { + get { + return ResourceManager.GetString("typelist_cmd", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lists added typing articles with their IDs. 15 per page.. + /// + public static string typelist_desc { + get { + return ResourceManager.GetString("typelist_desc", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to `{0}typelist` or `{0}typelist 3`. + /// + public static string typelist_usage { + get { + return ResourceManager.GetString("typelist_usage", resourceCulture); + } + } + /// /// Looks up a localized string similar to typestart. /// diff --git a/src/NadekoBot/Resources/CommandStrings.resx b/src/NadekoBot/Resources/CommandStrings.resx index 23fdb67f..10c72d72 100644 --- a/src/NadekoBot/Resources/CommandStrings.resx +++ b/src/NadekoBot/Resources/CommandStrings.resx @@ -2574,4 +2574,22 @@ Lists all quotes on the server ordered alphabetically. 15 Per page. + + typedel + + + Deletes a typing article given the ID. + + + `{0}typedel 3` + + + typelist + + + Lists added typing articles with their IDs. 15 per page. + + + `{0}typelist` or `{0}typelist 3` + \ No newline at end of file