From c02f50355759ec03310f7b6b46d77533d8c18a56 Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Sun, 20 Nov 2022 20:45:07 +0500 Subject: [PATCH] Fix wrong languages being used in some places --- Boyfriend/EventHandler.cs | 4 ++++ Boyfriend/Utils.cs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Boyfriend/EventHandler.cs b/Boyfriend/EventHandler.cs index 99318a7..a7805b6 100644 --- a/Boyfriend/EventHandler.cs +++ b/Boyfriend/EventHandler.cs @@ -110,6 +110,7 @@ public static class EventHandler { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); var channel = Utils.GetEventNotificationChannel(guild); + Utils.SetCurrentLanguage(guild.Id); if (channel is not null) { var role = guild.GetRole(ulong.Parse(eventConfig["EventNotificationRole"])); @@ -137,6 +138,7 @@ public static class EventHandler { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); var channel = Utils.GetEventNotificationChannel(guild); + Utils.SetCurrentLanguage(guild.Id); if (channel is not null) await channel.SendMessageAsync(string.Format(Messages.EventCancelled, Utils.Wrap(scheduledEvent.Name), eventConfig["FrowningFace"] is "true" ? $" {Messages.SettingsFrowningFace}" : "")); @@ -146,6 +148,7 @@ public static class EventHandler { var guild = scheduledEvent.Guild; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); var channel = Utils.GetEventNotificationChannel(guild); + Utils.SetCurrentLanguage(guild.Id); if (channel is not null) { var receivers = eventConfig["EventStartedReceivers"]; @@ -167,6 +170,7 @@ public static class EventHandler { private static async Task ScheduledEventCompletedEvent(SocketGuildEvent scheduledEvent) { var guild = scheduledEvent.Guild; var channel = Utils.GetEventNotificationChannel(guild); + Utils.SetCurrentLanguage(guild.Id); if (channel is not null) await channel.SendMessageAsync(string.Format(Messages.EventCompleted, Utils.Wrap(scheduledEvent.Name), Utils.GetHumanizedTimeOffset(DateTimeOffset.Now.Subtract(scheduledEvent.StartTime)))); diff --git a/Boyfriend/Utils.cs b/Boyfriend/Utils.cs index 95538b4..6fe8452 100644 --- a/Boyfriend/Utils.cs +++ b/Boyfriend/Utils.cs @@ -148,12 +148,14 @@ public static class Utils { public static async Task DelayedUnbanAsync(CommandProcessor cmd, ulong banned, string reason, TimeSpan duration) { await Task.Delay(duration); + SetCurrentLanguage(cmd.Context.Guild.Id); await UnbanCommand.UnbanUserAsync(cmd, banned, reason); } public static async Task DelayedUnmuteAsync(CommandProcessor cmd, SocketGuildUser muted, string reason, TimeSpan duration) { await Task.Delay(duration); + SetCurrentLanguage(cmd.Context.Guild.Id); await UnmuteCommand.UnmuteMemberAsync(cmd, muted, reason); } @@ -165,6 +167,7 @@ public static class Utils { var guild = scheduledEvent.Guild; if (guild.GetEvent(scheduledEvent.Id) is null) return; var eventConfig = Boyfriend.GetGuildConfig(guild.Id); + SetCurrentLanguage(guild.Id); var receivers = eventConfig["EventStartedReceivers"]; var role = guild.GetRole(ulong.Parse(eventConfig["EventNotificationRole"]));