2020-08-14 03:30:54 +02:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Threading;
|
|
|
|
using Discord.Commands;
|
2020-08-14 23:15:11 +02:00
|
|
|
using Geekbot.Core.Database.Models;
|
2020-08-14 03:30:54 +02:00
|
|
|
using Geekbot.Core.ErrorHandling;
|
2020-08-14 23:15:11 +02:00
|
|
|
using Geekbot.Core.GuildSettingsManager;
|
2020-08-14 03:30:54 +02:00
|
|
|
|
|
|
|
namespace Geekbot.Core
|
|
|
|
{
|
|
|
|
public class GeekbotCommandBase : ModuleBase<ICommandContext>
|
|
|
|
{
|
2020-08-14 23:15:11 +02:00
|
|
|
protected readonly IGuildSettingsManager GuildSettingsManager;
|
|
|
|
protected GuildSettingsModel GuildSettings;
|
2020-08-14 03:30:54 +02:00
|
|
|
protected readonly IErrorHandler ErrorHandler;
|
|
|
|
|
2020-08-14 23:15:11 +02:00
|
|
|
protected GeekbotCommandBase(IErrorHandler errorHandler, IGuildSettingsManager guildSettingsManager)
|
2020-08-14 03:30:54 +02:00
|
|
|
{
|
2020-08-14 23:15:11 +02:00
|
|
|
GuildSettingsManager = guildSettingsManager;
|
2020-08-14 03:30:54 +02:00
|
|
|
ErrorHandler = errorHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void BeforeExecute(CommandInfo command)
|
|
|
|
{
|
|
|
|
base.BeforeExecute(command);
|
2020-08-14 23:15:11 +02:00
|
|
|
GuildSettings = GuildSettingsManager.GetSettings(Context?.Guild?.Id ?? 0);
|
|
|
|
var language = GuildSettings.Language;
|
2020-08-14 03:30:54 +02:00
|
|
|
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(language == "CHDE" ? "de-ch" : language);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|