mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2025-09-11 01:38:27 -04:00
Merge branch 'v5' into 'v5'
Fix for timely reminder text See merge request Kwoth/nadekobot!332
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
using LinqToDB;
|
using LinqToDB;
|
||||||
using LinqToDB.EntityFrameworkCore;
|
using LinqToDB.EntityFrameworkCore;
|
||||||
using NadekoBot.Db;
|
|
||||||
using NadekoBot.Db.Models;
|
using NadekoBot.Db.Models;
|
||||||
using NadekoBot.Modules.Gambling.Bank;
|
using NadekoBot.Modules.Gambling.Bank;
|
||||||
using NadekoBot.Modules.Gambling.Common;
|
using NadekoBot.Modules.Gambling.Common;
|
||||||
@@ -149,6 +148,7 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
await smc.RespondConfirmAsync(_sender, GetText(strs.remind_timely(tt)), ephemeral: true);
|
await smc.RespondConfirmAsync(_sender, GetText(strs.remind_timely(tt)), ephemeral: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates timely reminder button, parameter in hours.
|
||||||
private NadekoInteractionBase CreateRemindMeInteraction(int period)
|
private NadekoInteractionBase CreateRemindMeInteraction(int period)
|
||||||
=> _inter
|
=> _inter
|
||||||
.Create(ctx.User.Id,
|
.Create(ctx.User.Id,
|
||||||
@@ -158,6 +158,17 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
customId: "timely:remind_me"),
|
customId: "timely:remind_me"),
|
||||||
(smc) => RemindTimelyAction(smc, DateTime.UtcNow.Add(TimeSpan.FromHours(period)))
|
(smc) => RemindTimelyAction(smc, DateTime.UtcNow.Add(TimeSpan.FromHours(period)))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Creates timely reminder button, parameter in milliseconds.
|
||||||
|
private NadekoInteractionBase CreateRemindMeInteraction(double ms)
|
||||||
|
=> _inter
|
||||||
|
.Create(ctx.User.Id,
|
||||||
|
new ButtonBuilder(
|
||||||
|
label: "Remind me",
|
||||||
|
emote: Emoji.Parse("⏰"),
|
||||||
|
customId: "timely:remind_me"),
|
||||||
|
(smc) => RemindTimelyAction(smc, DateTime.UtcNow.Add(TimeSpan.FromMilliseconds(ms)))
|
||||||
|
);
|
||||||
|
|
||||||
[Cmd]
|
[Cmd]
|
||||||
public async Task Timely()
|
public async Task Timely()
|
||||||
@@ -170,22 +181,26 @@ public partial class Gambling : GamblingModule<GamblingService>
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var inter = CreateRemindMeInteraction(period);
|
if (await _service.ClaimTimelyAsync(ctx.User.Id, period) is { } remainder)
|
||||||
|
|
||||||
if (await _service.ClaimTimelyAsync(ctx.User.Id, period) is { } rem)
|
|
||||||
{
|
{
|
||||||
|
// Get correct time form remainder
|
||||||
|
var interaction = CreateRemindMeInteraction(remainder.TotalMilliseconds);
|
||||||
|
|
||||||
// Removes timely button if there is a timely reminder in DB
|
// Removes timely button if there is a timely reminder in DB
|
||||||
if (_service.UserHasTimelyReminder(ctx.User.Id))
|
if (_service.UserHasTimelyReminder(ctx.User.Id))
|
||||||
{
|
{
|
||||||
inter = null;
|
interaction = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
var relativeTag = TimestampTag.FromDateTime(now.Add(rem), TimestampTagStyles.Relative);
|
var relativeTag = TimestampTag.FromDateTime(now.Add(remainder), TimestampTagStyles.Relative);
|
||||||
await Response().Pending(strs.timely_already_claimed(relativeTag)).Interaction(inter).SendAsync();
|
await Response().Pending(strs.timely_already_claimed(relativeTag)).Interaction(interaction).SendAsync();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var inter = CreateRemindMeInteraction(period);
|
||||||
|
|
||||||
|
var result = await _ps.TryGetFeatureLimitAsync(_timelyKey, ctx.User.Id, 0);
|
||||||
|
|
||||||
var patron = await _ps.GetPatronAsync(ctx.User.Id);
|
var patron = await _ps.GetPatronAsync(ctx.User.Id);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user