From 4069368beba479d617a340b3530131355b6d7958 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Thu, 28 Nov 2024 08:55:01 +0000 Subject: [PATCH] change: added ending date for givaway as a timestamp tag fixed: fixed an issue with flag translates --- src/NadekoBot/Db/Models/giveaway/GiveawayModel.cs | 1 + .../Modules/Searches/Translate/FlagTranslateService.cs | 5 ++++- src/NadekoBot/Modules/Utility/Giveaway/GiveawayCommands.cs | 2 ++ src/NadekoBot/data/strings/responses/responses.en-US.json | 4 +++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/NadekoBot/Db/Models/giveaway/GiveawayModel.cs b/src/NadekoBot/Db/Models/giveaway/GiveawayModel.cs index 6a64945e7..54f45d33e 100644 --- a/src/NadekoBot/Db/Models/giveaway/GiveawayModel.cs +++ b/src/NadekoBot/Db/Models/giveaway/GiveawayModel.cs @@ -8,6 +8,7 @@ public sealed class GiveawayModel public ulong MessageId { get; set; } public ulong ChannelId { get; set; } public string Message { get; set; } + public int Winners { get; set; } public IList Participants { get; set; } = new List(); public DateTime EndsAt { get; set; } diff --git a/src/NadekoBot/Modules/Searches/Translate/FlagTranslateService.cs b/src/NadekoBot/Modules/Searches/Translate/FlagTranslateService.cs index 8035d858c..2b4a12e9c 100644 --- a/src/NadekoBot/Modules/Searches/Translate/FlagTranslateService.cs +++ b/src/NadekoBot/Modules/Searches/Translate/FlagTranslateService.cs @@ -122,12 +122,15 @@ public sealed partial class FlagTranslateService : IReadyExecutor, INService if (!_supportedFlags.TryGetValue(code, out var lang)) return; - if (!_msgLangs.Add((reaction.MessageId, lang))) + if (_msgLangs.Contains((reaction.MessageId, lang))) return; var result = await _cache.GetAsync(CdKey(reaction.UserId)); if (result.TryPickT0(out _, out _)) return; + + if (!_msgLangs.Add((reaction.MessageId, lang))) + return; await _cache.AddAsync(CdKey(reaction.UserId), true, TimeSpan.FromSeconds(5)); diff --git a/src/NadekoBot/Modules/Utility/Giveaway/GiveawayCommands.cs b/src/NadekoBot/Modules/Utility/Giveaway/GiveawayCommands.cs index 8a40574fa..5f79bc891 100644 --- a/src/NadekoBot/Modules/Utility/Giveaway/GiveawayCommands.cs +++ b/src/NadekoBot/Modules/Utility/Giveaway/GiveawayCommands.cs @@ -38,6 +38,8 @@ public partial class Utility eb .WithOkColor() .WithTitle(GetText(strs.giveaway_started)) + .AddField(GetText(strs.lasts_until), TimestampTag.FromDateTime(DateTime.UtcNow.Add(duration)), true) + // .AddField(GetText(strs.winners_count), "1", true) .WithFooter($"id: {new kwum(id).ToString()}"); await startingMsg.AddReactionAsync(new Emoji(GiveawayService.GiveawayEmoji)); diff --git a/src/NadekoBot/data/strings/responses/responses.en-US.json b/src/NadekoBot/data/strings/responses/responses.en-US.json index c627928e3..321b0478a 100644 --- a/src/NadekoBot/data/strings/responses/responses.en-US.json +++ b/src/NadekoBot/data/strings/responses/responses.en-US.json @@ -1135,5 +1135,7 @@ "no_last_queued_found": "No last queued track found.", "wrongsong_success": "Oops! Wrong song removed: {0}", "server_not_found": "Server not found.", - "server_color_set": "Successfully set a new server color." + "server_color_set": "Successfully set a new server color.", + "lasts_until": "Lasts Until", + "winners_count": "Winners" }