Compare commits

..

4 Commits
5.2.1 ... 5.2.3

Author SHA1 Message Date
Kwoth
62a16f3faf fix: fixed .iam
fix: fixed .sclr not being respected on many different commands
change: .rps now also has the amount bet
2024-11-27 02:41:05 +00:00
Kwoth
231451f978 fix: fixed .sclr again 2024-11-27 01:28:17 +00:00
Kwoth
2bed4e7eac fix: Fixed many issues with 5.2.0 2024-11-27 01:23:38 +00:00
Kwoth
22eea3fa7b docs: updated changelog 2024-11-26 23:49:32 +00:00
13 changed files with 92 additions and 37 deletions

View File

@@ -2,6 +2,35 @@
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## [5.2.3] - 27.11.2024
## Fixed
- `.iam` Fixed
- `.sclr` will now properly change color on many commands it didn't work previously
### Changed
- `.rps` now also has bet amount in the result, like other gambling commands
## [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 self assigned missing
## [5.2.0] - 26.11.2024
### Added

View File

@@ -21,16 +21,13 @@ 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)
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 FROM GroupName as gn
INNER JOIN (SELECT GuildId, gn.Number FROM GroupName as gn
INNER JOIN GuildConfigs as gc ON gn.GuildConfigId =gc.Id
) 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"
WHERE SG.Number IN (SELECT GroupNumber FROM SarGroup WHERE Sar.GuildId = SarGroup.GuildId)
GROUP BY SAR.GuildId, SAR.RoleId;
INSERT INTO SarAutoDelete (GuildId, IsEnabled)

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

@@ -21,7 +21,7 @@ public partial class Administration
{
var guildUser = (IGuildUser)ctx.User;
var group = await _service.GetRoleGroup(ctx.User.Id, role.Id);
var group = await _service.GetRoleGroup(ctx.Guild.Id, role.Id);
IUserMessage msg = null;
try
@@ -90,7 +90,7 @@ public partial class Administration
return;
}
var group = await _service.GetRoleGroup(role.Guild.Id, role.Id);
var group = await _service.GetRoleGroup(ctx.Guild.Id, role.Id);
if (group is null || group.Roles.All(x => x.RoleId != role.Id))
{

View File

@@ -872,9 +872,6 @@ public partial class Gambling : GamblingModule<GamblingService>
}
else if (result.Result == RpsResultType.Win)
{
if ((long)result.Won > 0)
embed.AddField(GetText(strs.won), N((long)result.Won));
msg = GetText(strs.rps_win(ctx.User.Mention,
GetRpsPick(pick),
GetRpsPick((InputRpsPick)result.ComputerPick)));
@@ -890,6 +887,13 @@ public partial class Gambling : GamblingModule<GamblingService>
.WithOkColor()
.WithDescription(msg);
if (amount > 0)
{
embed
.AddField(GetText(strs.bet), N(amount), true)
.AddField(GetText(strs.won), $"{N((long)result.Won)}", true);
}
await Response().Embed(embed).SendAsync();
}

View File

@@ -14,7 +14,7 @@ public partial class Utility
}
private string GetCommandString(NadekoCommandCallModel res)
=> $"{_bcs.Data.Prefix}{res.Name} {res.Arguments.Select((x, i) => GetParamString(x, i + 1 == res.Arguments.Count)).Join(" ")}";
=> $"{prefix}{res.Name} {res.Arguments.Select((x, i) => GetParamString(x, i + 1 == res.Arguments.Count)).Join(" ")}";
private static string GetParamString(string val, bool isLast)
=> isLast ? val : "\"" + val + "\"";

View File

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

View File

@@ -19,7 +19,6 @@ public abstract class NadekoModule : ModuleBase
public INadekoInteractionService _inter { get; set; }
public IReplacementService repSvc { get; set; }
public IMessageSenderService _sender { get; set; }
public BotConfigService _bcs { get; set; }
protected string prefix
=> _cmdHandler.GetPrefix(ctx.Guild);
@@ -31,7 +30,7 @@ public abstract class NadekoModule : ModuleBase
=> _sender.CreateEmbed(ctx.Guild?.Id);
public ResponseBuilder Response()
=> new ResponseBuilder(Strings, _bcs, (DiscordSocketClient)ctx.Client)
=> new ResponseBuilder(Strings, _sender, (DiscordSocketClient)ctx.Client)
.Context(ctx);
protected override void BeforeExecute(CommandInfo command)

View File

@@ -9,31 +9,31 @@ public sealed class MessageSenderService : IMessageSenderService, INService
public MessageSenderService(
IBotStrings bs,
BotConfigService bcs,
DiscordSocketClient client,
IGuildColorsService gcs)
IGuildColorsService gcs,
BotConfigService bcs)
{
_bs = bs;
_bcs = bcs;
_client = client;
_gcs = gcs;
_bcs = bcs;
}
public ResponseBuilder Response(IMessageChannel channel)
=> new ResponseBuilder(_bs, _bcs, _client)
=> new ResponseBuilder(_bs, this, _client)
.Channel(channel);
public ResponseBuilder Response(ICommandContext ctx)
=> new ResponseBuilder(_bs, _bcs, _client)
=> new ResponseBuilder(_bs, this, _client)
.Context(ctx);
public ResponseBuilder Response(IUser user)
=> new ResponseBuilder(_bs, _bcs, _client)
=> new ResponseBuilder(_bs, this, _client)
.User(user);
public ResponseBuilder Response(SocketMessageComponent smc)
=> new ResponseBuilder(_bs, _bcs, _client)
=> new ResponseBuilder(_bs, this, _client)
.Channel(smc.Channel);
public NadekoEmbedBuilder CreateEmbed(ulong? guildId = null)

View File

@@ -6,16 +6,17 @@ public sealed partial class ResponseBuilder
{
private ICommandContext? ctx;
private IMessageChannel? channel;
private IUser? user;
private IUserMessage? msg;
private string? plainText;
private IReadOnlyCollection<EmbedBuilder>? embeds;
private IUserMessage? msg;
private IUser? user;
private bool sanitizeMentions = true;
private LocStr? locTxt;
private object[] locParams = [];
private bool shouldReply = true;
private readonly IBotStrings _bs;
private readonly BotConfigService _bcs;
private readonly IMessageSenderService _sender;
private EmbedBuilder? embedBuilder;
private NadekoInteractionBase? inter;
private Stream? fileStream;
@@ -25,10 +26,10 @@ public sealed partial class ResponseBuilder
public DiscordSocketClient Client { get; set; }
public ResponseBuilder(IBotStrings bs, BotConfigService bcs, DiscordSocketClient client)
public ResponseBuilder(IBotStrings bs, IMessageSenderService sender, DiscordSocketClient client)
{
_bs = bs;
_bcs = bcs;
_sender = sender;
Client = client;
}
@@ -197,7 +198,7 @@ public sealed partial class ResponseBuilder
string? url = null,
string? footer = null)
{
var eb = new NadekoEmbedBuilder(_bcs)
var eb = _sender.CreateEmbed(ctx?.Guild?.Id ?? (channel as ITextChannel)?.GuildId ?? (user as IGuildUser)?.GuildId)
.WithDescription(text);
if (!string.IsNullOrWhiteSpace(title))

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
{
Error = 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
{
Pending = color?.ToDiscordColor()
};
}
}
public async Task OnReadyAsync()

View File

@@ -9,7 +9,7 @@ public static class SocketMessageComponentExtensions
MsgType type,
bool ephemeral = false)
{
var embed = sender.CreateEmbed().WithDescription(text);
var embed = sender.CreateEmbed(ch.GuildId).WithDescription(text);
embed = (type switch
{