Skip to content

Commit

Permalink
change: timely 'password' is now a button
Browse files Browse the repository at this point in the history
  • Loading branch information
Wizkiller96 committed Nov 6, 2024
1 parent 237c18d commit a9ec013
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src/WizBot/Modules/Gambling/Gambling.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
using WizBot.Modules.Gambling.Rps;
using WizBot.Common.TypeReaders;
using WizBot.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 WizBot.Modules.Gambling;

Expand Down Expand Up @@ -152,6 +144,18 @@ private WizBotInteractionBase CreateRemindMeInteraction(double ms)
(smc) => RemindTimelyAction(smc, DateTime.UtcNow.Add(TimeSpan.FromMilliseconds(ms)))
);

private WizBotInteractionBase 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()
{
Expand Down Expand Up @@ -214,10 +218,18 @@ public async Task Timely()
// _ = 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
Expand All @@ -236,6 +248,7 @@ public async Task Timely()
}


var val = Config.Timely.Amount;
var patron = await _ps.GetPatronAsync(ctx.User.Id);

var percentBonus = (_ps.PercentBonus(patron) / 100f);
Expand Down
1 change: 1 addition & 0 deletions src/WizBot/data/strings/responses/responses.en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,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.",
Expand Down

0 comments on commit a9ec013

Please sign in to comment.