From 746ffda946dc6b16860a6f9f4a3300a7b5eb87eb Mon Sep 17 00:00:00 2001 From: Toastie Date: Wed, 23 Oct 2024 19:32:12 +1300 Subject: [PATCH] fixed expire settings not returned on api --- .../Modules/Administration/UserPunish/UserPunishCommands.cs | 2 +- .../Modules/Administration/UserPunish/UserPunishService.cs | 4 ++-- src/EllieBot/Services/GrpcApi/WarnSvc.cs | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/EllieBot/Modules/Administration/UserPunish/UserPunishCommands.cs b/src/EllieBot/Modules/Administration/UserPunish/UserPunishCommands.cs index 4c365a5..85e5026 100644 --- a/src/EllieBot/Modules/Administration/UserPunish/UserPunishCommands.cs +++ b/src/EllieBot/Modules/Administration/UserPunish/UserPunishCommands.cs @@ -118,7 +118,7 @@ public partial class Administration [Priority(1)] public async Task WarnExpire() { - var expireDays = await _service.GetWarnExpire(ctx.Guild.Id); + var (expireDays, _) = await _service.GetWarnExpire(ctx.Guild.Id); if (expireDays == 0) await Response().Confirm(strs.warns_dont_expire).SendAsync(); diff --git a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs index 1fe26b2..2cfaaab 100644 --- a/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs +++ b/src/EllieBot/Modules/Administration/UserPunish/UserPunishService.cs @@ -330,11 +330,11 @@ public class UserPunishService : IEService, IReadyExecutor await uow.SaveChangesAsync(); } - public Task GetWarnExpire(ulong guildId) + public Task<(int, bool)> GetWarnExpire(ulong guildId) { using var uow = _db.GetDbContext(); var config = uow.GuildConfigsForId(guildId, set => set); - return Task.FromResult(config.WarnExpireHours / 24); + return Task.FromResult((config.WarnExpireHours / 24, config.WarnExpireAction == WarnExpireAction.Delete)); } public async Task WarnExpireAsync(ulong guildId, int days, bool delete) diff --git a/src/EllieBot/Services/GrpcApi/WarnSvc.cs b/src/EllieBot/Services/GrpcApi/WarnSvc.cs index 889a1ff..b67cec7 100644 --- a/src/EllieBot/Services/GrpcApi/WarnSvc.cs +++ b/src/EllieBot/Services/GrpcApi/WarnSvc.cs @@ -27,6 +27,8 @@ public sealed class WarnSvc : GrpcWarn.GrpcWarnBase, IGrpcSvc, IEService var wsr = new WarnSettingsReply(); + (wsr.ExpiryDays, wsr.DeleteOnExpire) = await _ups.GetWarnExpire(request.GuildId); + wsr.Punishments.AddRange(list.Select(x => new WarnPunishment() { Action = x.Punishment.ToString(),