From 2688d5f5e76f168107d151a0ad8ab694f8c88dd0 Mon Sep 17 00:00:00 2001 From: mctaylors Date: Mon, 1 Apr 2024 21:46:56 +0300 Subject: [PATCH] task (task) Signed-off-by: mctaylors --- src/Services/GuildDataService.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Services/GuildDataService.cs b/src/Services/GuildDataService.cs index c9458a0..4647b11 100644 --- a/src/Services/GuildDataService.cs +++ b/src/Services/GuildDataService.cs @@ -78,7 +78,7 @@ public sealed class GuildDataService : BackgroundService var settingsPath = $"{path}/Settings.json"; var scheduledEventsPath = $"{path}/ScheduledEvents.json"; - MigrateGuildData(guildId, path); + await MigrateGuildData(guildId, path, ct); Directory.CreateDirectory(path); @@ -155,7 +155,7 @@ public sealed class GuildDataService : BackgroundService return finalData; } - private void MigrateGuildData(Snowflake guildId, string newPath) + private async Task MigrateGuildData(Snowflake guildId, string newPath, CancellationToken ct) { var oldPath = $"{guildId}"; @@ -167,6 +167,14 @@ public sealed class GuildDataService : BackgroundService _logger.LogInformation("Moved guild data to separate folder: \"{OldPath}\" -> \"{NewPath}\"", oldPath, newPath); } + + var settings = (await GetData(guildId, ct)).Settings; + + if (GuildSettings.Language.Get(settings).Name is "tt-RU") + { + GuildSettings.Language.Set(settings, "ru"); + _logger.LogInformation("Switched from unsupported language in \"{GuildID}\": mctaylors-ru -> ru", guildId.Value); + } } public async Task GetSettings(Snowflake guildId, CancellationToken ct = default)