From 786646218c82ed741e28b2c65a2ac0240b30e761 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 29 Nov 2024 18:12:21 +1300 Subject: [PATCH] Fixed many issues with 5.2.0 --- CHANGELOG.md | 2 +- src/EllieBot/Migrations/MigrationQueries.cs | 15 ++++++--------- .../Administration/Role/ButtonRolesCommands.cs | 8 +++++++- .../Administration/Role/ButtonRolesService.cs | 9 ++++++--- .../_common/Services/Impl/GuildColorsService.cs | 4 ++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d65da6..4dcfd64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except da ### Fixed -- Fixed old .sar missing +- Fixed old self assigned missing ## [5.2.0] - 28.11.2024 diff --git a/src/EllieBot/Migrations/MigrationQueries.cs b/src/EllieBot/Migrations/MigrationQueries.cs index 2f81412..c68376c 100644 --- a/src/EllieBot/Migrations/MigrationQueries.cs +++ b/src/EllieBot/Migrations/MigrationQueries.cs @@ -21,17 +21,14 @@ public static class MigrationQueries INNER JOIN GuildConfigs as GC ON GN.GuildConfigId = GC.Id; INSERT INTO Sar (GuildId, RoleId, SarGroupId, LevelReq) - SELECT SAR.GuildId, SAR.RoleId, SG2.Id, MIN(SAR.LevelRequirement) - FROM SelfAssignableRoles as SAR - INNER JOIN (SELECT GuildId FROM GroupName as gn + SELECT SAR.GuildId, SAR.RoleId, (SELECT Id FROM SarGroup WHERE SG.Number = SarGroup.GroupNumber AND SG.GuildId = SarGroup.GuildId), MIN(SAR.LevelRequirement) + FROM SelfAssignableRoles as SAR + INNER JOIN (SELECT GuildId, gn.Number FROM GroupName as gn INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id - ) as SG + ) as SG ON SG.GuildId = SAR.GuildId - INNER JOIN (SELECT gn.Id, Number FROM GroupName as gn - INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id - ) as SG2 - ON SG2.Number = SAR."Group" - GROUP BY SAR.GuildId, SAR.RoleId; + WHERE SG.Number IN (SELECT GroupNumber FROM SarGroup WHERE Sar.GuildId = SarGroup.GuildId) + GROUP BY SAR.GuildId, SAR.RoleId; INSERT INTO SarAutoDelete (GuildId, IsEnabled) SELECT GuildId, AutoDeleteSelfAssignedRoleMessages FROM GuildConfigs WHERE AutoDeleteSelfAssignedRoleMessages = TRUE; diff --git a/src/EllieBot/Modules/Administration/Role/ButtonRolesCommands.cs b/src/EllieBot/Modules/Administration/Role/ButtonRolesCommands.cs index 4896c0a..51931a2 100644 --- a/src/EllieBot/Modules/Administration/Role/ButtonRolesCommands.cs +++ b/src/EllieBot/Modules/Administration/Role/ButtonRolesCommands.cs @@ -283,7 +283,13 @@ public partial class Administration { var res = await _service.SetExclusiveButtonRoles(ctx.Guild.Id, messageId, exclusive.Value); - if (res) + if (!res) + { + await Response().Error(strs.btnrole_not_found).SendAsync(); + return; + } + + if (exclusive.Value) { await Response().Confirm(strs.btnrole_exclusive).SendAsync(); } diff --git a/src/EllieBot/Modules/Administration/Role/ButtonRolesService.cs b/src/EllieBot/Modules/Administration/Role/ButtonRolesService.cs index 3dc076b..51f5f85 100644 --- a/src/EllieBot/Modules/Administration/Role/ButtonRolesService.cs +++ b/src/EllieBot/Modules/Administration/Role/ButtonRolesService.cs @@ -126,7 +126,11 @@ public sealed class ButtonRolesService : IEService, IReadyExecutor Emote = emoteStr, Label = string.Empty, ButtonId = $"{BTN_PREFIX}:{guildId}:{guid}", - Exclusive = (uow.GetTable().Where(x => x.GuildId == guildId && x.MessageId == messageId).All(x => x.Exclusive)) + Exclusive = uow.GetTable() + .Any(x => x.GuildId == guildId && x.MessageId == messageId) + && uow.GetTable() + .Where(x => x.GuildId == guildId && x.MessageId == messageId) + .All(x => x.Exclusive) }, _ => new() { @@ -178,7 +182,6 @@ public sealed class ButtonRolesService : IEService, IReadyExecutor .UpdateAsync((_) => new() { Exclusive = exclusive - }) - > 0; + }) > 0; } } \ No newline at end of file diff --git a/src/EllieBot/_common/Services/Impl/GuildColorsService.cs b/src/EllieBot/_common/Services/Impl/GuildColorsService.cs index 86143ff..04e2ec3 100644 --- a/src/EllieBot/_common/Services/Impl/GuildColorsService.cs +++ b/src/EllieBot/_common/Services/Impl/GuildColorsService.cs @@ -80,7 +80,7 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IE { _colors[guildId] = _colors[guildId] with { - Error = color?.ToDiscordColor() + Ok = color?.ToDiscordColor() }; } } @@ -108,7 +108,7 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IE { _colors[guildId] = _colors[guildId] with { - Pending = color?.ToDiscordColor() + Ok = color?.ToDiscordColor() }; } }