diff --git a/src/EllieBot/Modules/Administration/DangerousCommands/CleanupCommands.cs b/src/EllieBot/Modules/Administration/DangerousCommands/CleanupCommands.cs index c9d9bb2..55deace 100644 --- a/src/EllieBot/Modules/Administration/DangerousCommands/CleanupCommands.cs +++ b/src/EllieBot/Modules/Administration/DangerousCommands/CleanupCommands.cs @@ -42,7 +42,7 @@ public partial class Administration [Cmd] [OwnerOnly] - public async Task LeaveUnkeptServers() + public async Task LeaveUnkeptServers(int shardId = 0) { var keptGuildCount = await _svc.GetKeptGuildCount(); @@ -58,7 +58,7 @@ public partial class Administration if (!response) return; - await _svc.LeaveUnkeptServers(); + await _svc.LeaveUnkeptServers(shardId); await ctx.OkAsync(); } } diff --git a/src/EllieBot/Modules/Administration/DangerousCommands/CleanupService.cs b/src/EllieBot/Modules/Administration/DangerousCommands/CleanupService.cs index 86d077d..dc84027 100644 --- a/src/EllieBot/Modules/Administration/DangerousCommands/CleanupService.cs +++ b/src/EllieBot/Modules/Administration/DangerousCommands/CleanupService.cs @@ -14,7 +14,7 @@ public sealed class CleanupService : ICleanupService, IReadyExecutor, IEService private TypedKey _cleanupReportKey = new("cleanup:report"); private TypedKey _cleanupTriggerKey = new("cleanup:trigger"); - private TypedKey _keepTriggerKey = new("keep:trigger"); + private TypedKey _keepTriggerKey = new("keep:trigger"); private readonly IPubSub _pubSub; private readonly DiscordSocketClient _client; @@ -47,8 +47,11 @@ public sealed class CleanupService : ICleanupService, IReadyExecutor, IEService private bool keepTriggered = false; - private async ValueTask InternalTriggerKeep(bool arg) + private async ValueTask InternalTriggerKeep(int shardId) { + if (_client.ShardId != shardId) + return; + if (keepTriggered) return; @@ -80,7 +83,7 @@ public sealed class CleanupService : ICleanupService, IReadyExecutor, IEService continue; // 1 leave per 20 seconds per shard - await Task.Delay(RandomNumberGenerator.GetInt32(18_000, 22_000)); + await Task.Delay(500); SocketGuild? guild = null; try @@ -236,8 +239,8 @@ public sealed class CleanupService : ICleanupService, IReadyExecutor, IEService return await table.CountAsync(); } - public async Task LeaveUnkeptServers() - => await _pubSub.Pub(_keepTriggerKey, true); + public async Task LeaveUnkeptServers(int shardId) + => await _pubSub.Pub(_keepTriggerKey, shardId); private ValueTask OnKeepReport(KeepReport report) { diff --git a/src/EllieBot/Modules/Administration/DangerousCommands/_common/ICleanupService.cs b/src/EllieBot/Modules/Administration/DangerousCommands/_common/ICleanupService.cs index e48bba4..318197c 100644 --- a/src/EllieBot/Modules/Administration/DangerousCommands/_common/ICleanupService.cs +++ b/src/EllieBot/Modules/Administration/DangerousCommands/_common/ICleanupService.cs @@ -5,5 +5,5 @@ public interface ICleanupService Task DeleteMissingGuildDataAsync(); Task KeepGuild(ulong guildId); Task GetKeptGuildCount(); - Task LeaveUnkeptServers(); + Task LeaveUnkeptServers(int shardId); } \ No newline at end of file