From 558e05156c4263cf82c1f9a03376947e255a10ad Mon Sep 17 00:00:00 2001 From: Octol1ttle Date: Mon, 16 Jan 2023 21:51:25 +0500 Subject: [PATCH] Fix CI alerts again --- Boyfriend/Boyfriend.cs | 5 ++++- Boyfriend/Commands/SettingsCommand.cs | 12 +++++++++++- Boyfriend/Commands/UnbanCommand.cs | 2 +- Boyfriend/EventHandler.cs | 6 ++++++ Boyfriend/ReplyEmojis.cs | 1 - 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Boyfriend/Boyfriend.cs b/Boyfriend/Boyfriend.cs index 8d3e07c..1e2f489 100644 --- a/Boyfriend/Boyfriend.cs +++ b/Boyfriend/Boyfriend.cs @@ -57,6 +57,7 @@ public static class Boyfriend { timer.Interval = 1000; timer.AutoReset = true; timer.Elapsed += TickAllGuildsAsync; + if (ActivityList.Length is 0) timer.Dispose(); // CodeQL moment timer.Start(); while (ActivityList.Length > 0) @@ -143,7 +144,7 @@ public static class Boyfriend { await Utils.UnmuteMemberAsync(data, Client.CurrentUser.ToString(), guild.GetUser(mData.Id), Messages.PunishmentExpired); - foreach (var reminder in mData.Reminders) { + foreach (var reminder in mData.Reminders.Where(rem => DateTimeOffset.Now >= rem.RemindAt)) { var channel = guild.GetTextChannel(reminder.ReminderChannel); if (channel is null) { await Utils.SendDirectMessage(Client.GetUser(mData.Id), reminder.ReminderText); @@ -151,6 +152,8 @@ public static class Boyfriend { } await channel.SendMessageAsync($"<@{mData.Id}> {Utils.Wrap(reminder.ReminderText)}"); + + mData.Reminders.Remove(reminder); } } } diff --git a/Boyfriend/Commands/SettingsCommand.cs b/Boyfriend/Commands/SettingsCommand.cs index ed5392a..7ed012c 100644 --- a/Boyfriend/Commands/SettingsCommand.cs +++ b/Boyfriend/Commands/SettingsCommand.cs @@ -135,7 +135,17 @@ public sealed class SettingsCommand : ICommand { return Task.CompletedTask; } - if (selectedSetting is "MuteRole") data.MuteRole = guild.GetRole(mention); + switch (selectedSetting) { + case "MuteRole": + data.MuteRole = guild.GetRole(mention); + break; + case "PublicFeedbackChannel": + data.PublicFeedbackChannel = guild.GetTextChannel(mention); + break; + case "PrivateFeedbackChannel": + data.PrivateFeedbackChannel = guild.GetTextChannel(mention); + break; + } config[selectedSetting] = value; } diff --git a/Boyfriend/Commands/UnbanCommand.cs b/Boyfriend/Commands/UnbanCommand.cs index f1eb9e6..70abfe1 100644 --- a/Boyfriend/Commands/UnbanCommand.cs +++ b/Boyfriend/Commands/UnbanCommand.cs @@ -14,7 +14,7 @@ public sealed class UnbanCommand : ICommand { if (reason is not null) await UnbanUserAsync(cmd, id.Value, reason); } - public static async Task UnbanUserAsync(CommandProcessor cmd, ulong id, string reason) { + private static async Task UnbanUserAsync(CommandProcessor cmd, ulong id, string reason) { var requestOptions = Utils.GetRequestOptions($"({cmd.Context.User}) {reason}"); await cmd.Context.Guild.RemoveBanAsync(id, requestOptions); diff --git a/Boyfriend/EventHandler.cs b/Boyfriend/EventHandler.cs index fedddce..7badd28 100644 --- a/Boyfriend/EventHandler.cs +++ b/Boyfriend/EventHandler.cs @@ -17,12 +17,18 @@ public static class EventHandler { Client.MessageUpdated += MessageUpdatedEvent; Client.UserJoined += UserJoinedEvent; Client.UserLeft += UserLeftEvent; + Client.GuildMemberUpdated += RolesUpdatedEvent; Client.GuildScheduledEventCreated += ScheduledEventCreatedEvent; Client.GuildScheduledEventCancelled += ScheduledEventCancelledEvent; Client.GuildScheduledEventStarted += ScheduledEventStartedEvent; Client.GuildScheduledEventCompleted += ScheduledEventCompletedEvent; } + private static Task RolesUpdatedEvent(Cacheable oldUser, SocketGuildUser newUser) { + GuildData.Get(newUser.Guild).MemberData[newUser.Id].Roles = ((IGuildUser)newUser).RoleIds.ToList(); + return Task.CompletedTask; + } + private static Task ReadyEvent() { if (!_sendReadyMessages) return Task.CompletedTask; var i = Random.Shared.Next(3); diff --git a/Boyfriend/ReplyEmojis.cs b/Boyfriend/ReplyEmojis.cs index c26d420..a4e8c40 100644 --- a/Boyfriend/ReplyEmojis.cs +++ b/Boyfriend/ReplyEmojis.cs @@ -2,7 +2,6 @@ namespace Boyfriend; public static class ReplyEmojis { public const string Success = ":white_check_mark:"; - public const string Warning = ":warning:"; public const string Error = ":x:"; public const string MissingArgument = ":keyboard:"; public const string InvalidArgument = ":construction:";