Cleanup, now compiles! :O

This commit is contained in:
Kwoth
2017-02-13 11:12:13 +01:00
parent db79177f0c
commit a1e25f5149
7 changed files with 76 additions and 34 deletions

View File

@@ -27,43 +27,38 @@ namespace NadekoBot.Modules
? CultureInfo.CurrentCulture
: NadekoBot.Localization.GetCultureInfo(Context.Guild));
}
public Task<IUserMessage> ConfirmLocalized(string titleKey, string textKey, string url = null, string footer = null)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendConfirmAsync(title, text, url, footer);
}
public Task<IUserMessage> ConfirmLocalized(string textKey)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendConfirmAsync(textKey);
}
public Task<IUserMessage> ErrorLocalized(string titleKey, string textKey, string url = null, string footer = null)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendErrorAsync(title, text, url, footer);
}
public Task<IUserMessage> ErrorLocalized(string textKey)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, cultureInfo);
return Context.Channel.SendErrorAsync(textKey);
}
}
public abstract class NadekoSubmodule : NadekoModule
{
public NadekoSubmodule() : base(false)
{
}
}
public static class ModuleBaseExtensions
{
public static Task<IUserMessage> ConfirmLocalized(this NadekoModule module, string titleKey, string textKey, string url = null, string footer = null)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, module.cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, module.cultureInfo);
return module.Context.Channel.SendConfirmAsync(title, text, url, footer);
}
public static Task<IUserMessage> ConfirmLocalized(this NadekoModule module, string textKey)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, module.cultureInfo);
return module.Context.Channel.SendConfirmAsync(textKey);
}
public static Task<IUserMessage> ErrorLocalized(this NadekoModule module, string titleKey, string textKey, string url = null, string footer = null)
{
var title = NadekoBot.ResponsesResourceManager.GetString(titleKey, module.cultureInfo);
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, module.cultureInfo);
return module.Context.Channel.SendErrorAsync(title, text, url, footer);
}
public static Task<IUserMessage> ErrorLocalized(this NadekoModule module, string textKey)
{
var text = NadekoBot.ResponsesResourceManager.GetString(textKey, module.cultureInfo);
return module.Context.Channel.SendErrorAsync(textKey);
}
}
}

View File

@@ -0,0 +1,15 @@
using Discord;
using NadekoBot.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Modules
{
public static class NadekoModuleExtensions
{
}
}

View File

@@ -12,6 +12,8 @@ using System;
using Newtonsoft.Json;
using System.IO;
using System.Collections.Concurrent;
using NadekoBot.Modules;
using NadekoBot.Resources;
namespace NadekoBot.Modules.Pokemon
{
@@ -105,12 +107,12 @@ namespace NadekoBot.Modules.Pokemon
if (targetUser == null)
{
await ReplyLocalized("no user found").ConfigureAwait(false);
await ErrorLocalized(nameof(ResponseStrings.Culture)).ConfigureAwait(false);
return;
}
else if (targetUser == user)
{
await Context.Channel.SendMessageAsync("You can't attack yourself.").ConfigureAwait(false);
await ErrorLocalized("You can't attack yourself.").ConfigureAwait(false);
return;
}