Ejemplo n.º 1
0
        private void SaveToSettingsFile(DiscordGuild server)
        {
            LanguageID   lang;
            TimeZoneInfo timezone;

            try
            {
                lang = Localization.Language[server];
            }
            catch
            {
                lang = Settings.LanguageDefault;
            }
            try
            {
                timezone = Settings.TimeZone[server];
            }
            catch
            {
                timezone = TimeZoneInfo.Utc;
            }
            var settings = new Setup.SettingsSerializable();

            settings.Initialize(server.Id, lang, timezone);
            Setup.SettingsSerializable.Serialize(settings);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set server-specific localization settings
        /// </summary>
        private async Task LoadServerSettingsAsync(DiscordGuild server)
        {
            if (!Directory.Exists(ServerSettingsFolder))
            {
                Directory.CreateDirectory(ServerSettingsFolder);
            }

            Commands.Setup.SettingsSerializable settings = null;
            try
            {
                settings = Commands.Setup.SettingsSerializable.Deserialize(server.Id);
                Localization.Language[server] = Localization.GetLanguageId(settings.Language);
                TimeZone[server] = TimeZoneInfo.FindSystemTimeZoneById(settings.TimezoneId);
            }
            catch
            {
                Localization.Language[server] = Settings.LanguageDefault;
                TimeZone[server] = TimeZoneInfo.Utc;
            }
        }