timely 'password' is now a button

This commit is contained in:
Toastie 2024-11-04 00:03:25 +13:00
parent 7f9a939285
commit c330d086b7
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
2 changed files with 24 additions and 10 deletions

View file

@ -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<GamblingService>
(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<GamblingService>
// _ = 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<GamblingService>
}
var val = Config.Timely.Amount;
var patron = await _ps.GetPatronAsync(ctx.User.Id);
var percentBonus = (_ps.PercentBonus(patron) / 100f);

View file

@ -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.",