fix: Fixed many issues with 5.2.0

This commit is contained in:
Kwoth
2024-11-27 01:23:03 +00:00
parent 22eea3fa7b
commit 2bed4e7eac
6 changed files with 49 additions and 15 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -126,7 +126,11 @@ public sealed class ButtonRolesService : INService, IReadyExecutor
Emote = emoteStr,
Label = string.Empty,
ButtonId = $"{BTN_PREFIX}:{guildId}:{guid}",
Exclusive = (uow.GetTable<ButtonRole>().Where(x => x.GuildId == guildId && x.MessageId == messageId).All(x => x.Exclusive))
Exclusive = uow.GetTable<ButtonRole>()
.Any(x => x.GuildId == guildId && x.MessageId == messageId)
&& uow.GetTable<ButtonRole>()
.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;
}
}

View File

@@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Version>5.2.1</Version>
<Version>5.2.2</Version>
<!-- Output/build -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>

View File

@@ -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()