Added >typelist and >typedel commands

This commit is contained in:
Kwoth 2016-10-28 13:14:16 +02:00
parent e8f6054c5a
commit bc4d37c0fa
3 changed files with 113 additions and 0 deletions

View File

@ -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);
}
}
}
}

View File

@ -6701,6 +6701,60 @@ namespace NadekoBot.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to typedel.
/// </summary>
public static string typedel_cmd {
get {
return ResourceManager.GetString("typedel_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Deletes a typing article given the ID..
/// </summary>
public static string typedel_desc {
get {
return ResourceManager.GetString("typedel_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}typedel 3`.
/// </summary>
public static string typedel_usage {
get {
return ResourceManager.GetString("typedel_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to typelist.
/// </summary>
public static string typelist_cmd {
get {
return ResourceManager.GetString("typelist_cmd", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Lists added typing articles with their IDs. 15 per page..
/// </summary>
public static string typelist_desc {
get {
return ResourceManager.GetString("typelist_desc", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to `{0}typelist` or `{0}typelist 3`.
/// </summary>
public static string typelist_usage {
get {
return ResourceManager.GetString("typelist_usage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to typestart.
/// </summary>

View File

@ -2574,4 +2574,22 @@
<data name="listquotes_usage" xml:space="preserve">
<value>Lists all quotes on the server ordered alphabetically. 15 Per page.</value>
</data>
<data name="typedel_cmd" xml:space="preserve">
<value>typedel</value>
</data>
<data name="typedel_desc" xml:space="preserve">
<value>Deletes a typing article given the ID.</value>
</data>
<data name="typedel_usage" xml:space="preserve">
<value>`{0}typedel 3`</value>
</data>
<data name="typelist_cmd" xml:space="preserve">
<value>typelist</value>
</data>
<data name="typelist_desc" xml:space="preserve">
<value>Lists added typing articles with their IDs. 15 per page.</value>
</data>
<data name="typelist_usage" xml:space="preserve">
<value>`{0}typelist` or `{0}typelist 3`</value>
</data>
</root>