From 2bed4e7eacfa2349b61e1463aa81a4353974ff3b Mon Sep 17 00:00:00 2001 From: Kwoth Date: Wed, 27 Nov 2024 01:23:03 +0000 Subject: [PATCH] fix: Fixed many issues with 5.2.0 --- CHANGELOG.md | 14 +++++++++++++- src/NadekoBot/Migrations/MigrationQueries.cs | 15 ++++++--------- .../Administration/Role/ButtonRolesCommands.cs | 8 +++++++- .../Administration/Role/ButtonRolesService.cs | 9 ++++++--- src/NadekoBot/NadekoBot.csproj | 2 +- .../_common/Services/Impl/GuildColorsService.cs | 16 ++++++++++++++++ 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4541ebcad..8f59f917f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,23 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o +## [5.2.2] - 27.11.2024 + +### Changed + +- Button roles are now non-exclusive by default + +### Fixed + +- Fixed sar migration, again (this time correctly) +- Fixed `.sclr` not updating unless bot is restarted, the changes should be immediate now for warn and error +- Fixed group buttons exclusivity message always saying groups are exclusive + ## [5.2.1] - 26.11.2024 ### Fixed -- Fixed old .sar missing +- Fixed old self assigned missing ## [5.2.0] - 26.11.2024 diff --git a/src/NadekoBot/Migrations/MigrationQueries.cs b/src/NadekoBot/Migrations/MigrationQueries.cs index 1a9586448..24c26f54d 100644 --- a/src/NadekoBot/Migrations/MigrationQueries.cs +++ b/src/NadekoBot/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/NadekoBot/Modules/Administration/Role/ButtonRolesCommands.cs b/src/NadekoBot/Modules/Administration/Role/ButtonRolesCommands.cs index c793238cc..6433a97fb 100644 --- a/src/NadekoBot/Modules/Administration/Role/ButtonRolesCommands.cs +++ b/src/NadekoBot/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/NadekoBot/Modules/Administration/Role/ButtonRolesService.cs b/src/NadekoBot/Modules/Administration/Role/ButtonRolesService.cs index 3514a393a..18c9125d2 100644 --- a/src/NadekoBot/Modules/Administration/Role/ButtonRolesService.cs +++ b/src/NadekoBot/Modules/Administration/Role/ButtonRolesService.cs @@ -126,7 +126,11 @@ public sealed class ButtonRolesService : INService, 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 : INService, IReadyExecutor .UpdateAsync((_) => new() { Exclusive = exclusive - }) - > 0; + }) > 0; } } \ No newline at end of file diff --git a/src/NadekoBot/NadekoBot.csproj b/src/NadekoBot/NadekoBot.csproj index cdfc7925a..5dde47632 100644 --- a/src/NadekoBot/NadekoBot.csproj +++ b/src/NadekoBot/NadekoBot.csproj @@ -4,7 +4,7 @@ enable true en - 5.2.1 + 5.2.2 $(MSBuildProjectDirectory) diff --git a/src/NadekoBot/_common/Services/Impl/GuildColorsService.cs b/src/NadekoBot/_common/Services/Impl/GuildColorsService.cs index ab2fe6998..ab925cf30 100644 --- a/src/NadekoBot/_common/Services/Impl/GuildColorsService.cs +++ b/src/NadekoBot/_common/Services/Impl/GuildColorsService.cs @@ -75,6 +75,14 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IN { GuildId = guildId }); + + if (!_colors.TryAdd(guildId, new Colors(null, null, color?.ToDiscordColor()))) + { + _colors[guildId] = _colors[guildId] with + { + Ok = color?.ToDiscordColor() + }; + } } public async Task SetPendingColor(ulong guildId, Rgba32? color) @@ -95,6 +103,14 @@ public sealed class GuildColorsService : IReadyExecutor, IGuildColorsService, IN { GuildId = guildId }); + + if (!_colors.TryAdd(guildId, new Colors(null, color?.ToDiscordColor(), null))) + { + _colors[guildId] = _colors[guildId] with + { + Ok = color?.ToDiscordColor() + }; + } } public async Task OnReadyAsync()