diff --git a/DiscordBot/Services/Moderation/IntroductionWatcherService.cs b/DiscordBot/Services/Moderation/IntroductionWatcherService.cs index 58b98387..6a82aa91 100644 --- a/DiscordBot/Services/Moderation/IntroductionWatcherService.cs +++ b/DiscordBot/Services/Moderation/IntroductionWatcherService.cs @@ -1,5 +1,6 @@ using Discord.WebSocket; using DiscordBot.Settings; +using DiscordBot.Services.UnityHelp; namespace DiscordBot.Services; @@ -15,6 +16,8 @@ public class IntroductionWatcherService private readonly HashSet _uniqueUsers = new HashSet(MaxMessagesToTrack + 1); private readonly Queue _orderedUsers = new Queue(MaxMessagesToTrack + 1); + private SocketRole ModeratorRole { get; set; } + private const int MaxMessagesToTrack = 1000; public IntroductionWatcherService(DiscordSocketClient client, ILoggingService loggingService, BotSettings settings) @@ -22,6 +25,8 @@ public IntroductionWatcherService(DiscordSocketClient client, ILoggingService lo _client = client; _loggingService = loggingService; + ModeratorRole = _client.GetGuild(settings.GuildId).GetRole(settings.ModeratorRoleId); + if (!settings.IntroductionWatcherServiceEnabled) { LoggingService.LogServiceDisabled(ServiceName, nameof(settings.IntroductionWatcherServiceEnabled)); @@ -43,7 +48,10 @@ private async Task MessageReceived(SocketMessage message) // We only watch the introduction channel if (_introductionChannel == null || message.Channel.Id != _introductionChannel.Id) return; - + + if (message.Author.HasRoleGroup(ModeratorRole)) + return; + if (_uniqueUsers.Contains(message.Author.Id)) { await message.DeleteAsync(); @@ -61,4 +69,4 @@ await _loggingService.LogChannelAndFile( await Task.CompletedTask; } -} \ No newline at end of file +}