From c330d086b79e02259a4321cf47779af7a8d436e0 Mon Sep 17 00:00:00 2001 From: Toastie Date: Mon, 4 Nov 2024 00:03:25 +1300 Subject: [PATCH] timely 'password' is now a button --- src/EllieBot/Modules/Gambling/Gambling.cs | 33 +++++++++++++------ .../strings/responses/responses.en-US.json | 1 + 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/EllieBot/Modules/Gambling/Gambling.cs b/src/EllieBot/Modules/Gambling/Gambling.cs index eb0026b..933eddd 100644 --- a/src/EllieBot/Modules/Gambling/Gambling.cs +++ b/src/EllieBot/Modules/Gambling/Gambling.cs @@ -14,14 +14,6 @@ using System.Text; using EllieBot.Modules.Gambling.Rps; using EllieBot.Common.TypeReaders; using EllieBot.Modules.Patronage; -using SixLabors.Fonts; -using SixLabors.Fonts.Unicode; -using SixLabors.ImageSharp; -using SixLabors.ImageSharp.Drawing.Processing; -using SixLabors.ImageSharp.PixelFormats; -using SixLabors.ImageSharp.Processing; -using Color = SixLabors.ImageSharp.Color; -using Random = System.Random; namespace EllieBot.Modules.Gambling; @@ -152,6 +144,18 @@ public partial class Gambling : GamblingModule (smc) => RemindTimelyAction(smc, DateTime.UtcNow.Add(TimeSpan.FromMilliseconds(ms))) ); + private EllieInteractionBase CreateTimelyInteraction() + => _inter + .Create(ctx.User.Id, + new ButtonBuilder( + label: "Timely", + emote: Emoji.Parse("💰"), + customId: "timely:" + _rng.Next(123456, 999999)), + async (smc) => + { + await ClaimTimely(); + }); + [Cmd] public async Task Timely() { @@ -214,10 +218,18 @@ public partial class Gambling : GamblingModule // _ = captcha.DeleteAsync(); // } - // await Response() - // .Interaction(_inter.Create(ctx.User.Id,new ButtonBuilder("Timely", $"timely:{rng}" Emoji.Parse("⏰")),null)) + var interaction = CreateTimelyInteraction(); + var msg = await Response().Pending(strs.timely_button).Interaction(interaction).SendAsync(); + await msg.DeleteAsync(); + return; } + await ClaimTimely(); + } + + private async Task ClaimTimely() + { + var period = Config.Timely.Cooldown; if (await _service.ClaimTimelyAsync(ctx.User.Id, period) is { } remainder) { // Get correct time form remainder @@ -236,6 +248,7 @@ public partial class Gambling : GamblingModule } + var val = Config.Timely.Amount; var patron = await _ps.GetPatronAsync(ctx.User.Id); var percentBonus = (_ps.PercentBonus(patron) / 100f); diff --git a/src/EllieBot/data/strings/responses/responses.en-US.json b/src/EllieBot/data/strings/responses/responses.en-US.json index 3e7abb3..d320027 100644 --- a/src/EllieBot/data/strings/responses/responses.en-US.json +++ b/src/EllieBot/data/strings/responses/responses.en-US.json @@ -622,6 +622,7 @@ "region": "Region", "remind2": "I will remind {0} to {1} {2} ({3})", "remind_timely": "I will remind you about your timely reward {0}", + "timely_button": "Click the button to claim your timely reward.", "remind_invalid": "Not a valid remind format. Remind must have a target, timer and a reason. Check the command list.", "remind_too_long": "Remind time has exceeded maximum.", "repeater_redundant_no": "Repeater **#{0}** won't post redundant messages anymore.",