fixed .iam

fixed .sclr not being respected on many different commands
.rps now also has the amount bet
This commit is contained in:
Toastie 2024-11-29 19:22:10 +13:00
parent ae54270d58
commit 65b7342421
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
9 changed files with 38 additions and 23 deletions

View file

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

View file

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

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(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 + "\"";

View file

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

View file

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

View file

@ -6,16 +6,17 @@ public sealed partial class ResponseBuilder
{
private ICommandContext? ctx;
private IMessageChannel? channel;
private string? plainText;
private IReadOnlyCollection<EmbedBuilder>? embeds;
private IUserMessage? msg;
private IUser? user;
private string? plainText;
private IReadOnlyCollection<EmbedBuilder>? 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))

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
{