From 49f04a594bfefefb93dcfa906a8974e67c67fcba Mon Sep 17 00:00:00 2001 From: Kwoth Date: Mon, 21 Oct 2024 04:36:54 +0000 Subject: [PATCH] fix: fixed expire settings not returned on api --- .../Modules/Administration/UserPunish/UserPunishCommands.cs | 2 +- .../Modules/Administration/UserPunish/UserPunishService.cs | 4 ++-- src/NadekoBot/Services/GrpcApi/WarnSvc.cs | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs b/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs index 6148e2d0a..1d8b2fe21 100644 --- a/src/NadekoBot/Modules/Administration/UserPunish/UserPunishCommands.cs +++ b/src/NadekoBot/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/NadekoBot/Modules/Administration/UserPunish/UserPunishService.cs b/src/NadekoBot/Modules/Administration/UserPunish/UserPunishService.cs index c01363bf6..3d023e3de 100644 --- a/src/NadekoBot/Modules/Administration/UserPunish/UserPunishService.cs +++ b/src/NadekoBot/Modules/Administration/UserPunish/UserPunishService.cs @@ -330,11 +330,11 @@ public class UserPunishService : INService, 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/NadekoBot/Services/GrpcApi/WarnSvc.cs b/src/NadekoBot/Services/GrpcApi/WarnSvc.cs index 8b8f7989c..cca256165 100644 --- a/src/NadekoBot/Services/GrpcApi/WarnSvc.cs +++ b/src/NadekoBot/Services/GrpcApi/WarnSvc.cs @@ -27,6 +27,8 @@ public sealed class WarnSvc : GrpcWarn.GrpcWarnBase, IGrpcSvc, INService 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(),