From cd1c4616908d5fdb67241511881d8fbed640d976 Mon Sep 17 00:00:00 2001 From: Toastie Date: Fri, 29 Nov 2024 19:22:10 +1300 Subject: [PATCH] fixed .iam fixed .sclr not being respected on many different commands .rps now also has the amount bet --- CHANGELOG.md | 11 +++++++++++ src/EllieBot/EllieBot.csproj | 2 +- .../SelfAssignedRolesCommands.cs | 4 ++-- src/EllieBot/Modules/Gambling/Gambling.cs | 10 +++++++--- src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs | 2 +- src/EllieBot/_common/EllieModule.cs | 3 +-- .../_common/Sender/MessageSenderService.cs | 14 +++++++------- src/EllieBot/_common/Sender/ResponseBuilder.cs | 13 +++++++------ .../SocketMessageComponentExtensions.cs | 2 +- 9 files changed, 38 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c52ce9..62000ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ Mostly based on [keepachangelog](https://keepachangelog.com/en/1.1.0/) except date format. a-c-f-r-o +## [5.2.3] - 29.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] - 29.11.2024 ### Changed diff --git a/src/EllieBot/EllieBot.csproj b/src/EllieBot/EllieBot.csproj index da51333..8855619 100644 --- a/src/EllieBot/EllieBot.csproj +++ b/src/EllieBot/EllieBot.csproj @@ -4,7 +4,7 @@ enable true en - 5.2.2 + 5.2.3 $(MSBuildProjectDirectory) diff --git a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs index 18a7871..73d6877 100644 --- a/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs +++ b/src/EllieBot/Modules/Administration/SelfAssignableRoles/SelfAssignedRolesCommands.cs @@ -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)) { diff --git a/src/EllieBot/Modules/Gambling/Gambling.cs b/src/EllieBot/Modules/Gambling/Gambling.cs index c4df107..35f3eb3 100644 --- a/src/EllieBot/Modules/Gambling/Gambling.cs +++ b/src/EllieBot/Modules/Gambling/Gambling.cs @@ -872,9 +872,6 @@ public partial class Gambling : GamblingModule } 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 .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(); } diff --git a/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs b/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs index 1fd6cfd..1b25754 100644 --- a/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs +++ b/src/EllieBot/Modules/Utility/Ai/UtilityCommands.cs @@ -14,7 +14,7 @@ public partial class Utility } private string GetCommandString(EllieCommandCallModel 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 + "\""; diff --git a/src/EllieBot/_common/EllieModule.cs b/src/EllieBot/_common/EllieModule.cs index 4e56663..92923f6 100644 --- a/src/EllieBot/_common/EllieModule.cs +++ b/src/EllieBot/_common/EllieModule.cs @@ -19,7 +19,6 @@ public abstract class EllieModule : ModuleBase public IEllieInteractionService _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 EllieModule : 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) diff --git a/src/EllieBot/_common/Sender/MessageSenderService.cs b/src/EllieBot/_common/Sender/MessageSenderService.cs index 0ab3096..f6e3205 100644 --- a/src/EllieBot/_common/Sender/MessageSenderService.cs +++ b/src/EllieBot/_common/Sender/MessageSenderService.cs @@ -9,31 +9,31 @@ public sealed class MessageSenderService : IMessageSenderService, IEService 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 EllieEmbedBuilder CreateEmbed(ulong? guildId = null) diff --git a/src/EllieBot/_common/Sender/ResponseBuilder.cs b/src/EllieBot/_common/Sender/ResponseBuilder.cs index f209770..d5e2d97 100644 --- a/src/EllieBot/_common/Sender/ResponseBuilder.cs +++ b/src/EllieBot/_common/Sender/ResponseBuilder.cs @@ -6,16 +6,17 @@ public sealed partial class ResponseBuilder { private ICommandContext? ctx; private IMessageChannel? channel; - private string? plainText; - private IReadOnlyCollection? embeds; private IUserMessage? msg; private IUser? user; + + private string? plainText; + private IReadOnlyCollection? embeds; 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 EllieInteractionBase? 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 EllieEmbedBuilder(_bcs) + var eb = _sender.CreateEmbed(ctx?.Guild?.Id ?? (channel as ITextChannel)?.GuildId ?? (user as IGuildUser)?.GuildId) .WithDescription(text); if (!string.IsNullOrWhiteSpace(title)) diff --git a/src/EllieBot/_common/_Extensions/SocketMessageComponentExtensions.cs b/src/EllieBot/_common/_Extensions/SocketMessageComponentExtensions.cs index 1b99fa7..4fa94bc 100644 --- a/src/EllieBot/_common/_Extensions/SocketMessageComponentExtensions.cs +++ b/src/EllieBot/_common/_Extensions/SocketMessageComponentExtensions.cs @@ -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 {