Updated mines to hopefully fix a timing bug introduced by the 15 second delay. Extended the schedule auto delete functionality so that it can apply to any message, even ones not owned by the bot.

This commit is contained in:
barelyprofessional
2026-05-10 11:23:38 -05:00
parent 5e2dc25c77
commit 07169f0837
2 changed files with 32 additions and 2 deletions

View File

@@ -298,7 +298,11 @@ public class KasinoMines
{
await GetSavedGames(gamblerId);
//attempt to delete the message if its there
if (ActiveGames[gamblerId].LastMessageId != null) await _kfChatBot.KfClient.DeleteMessageAsync(ActiveGames[gamblerId].LastMessageId!);
var lastMsgId = ActiveGames[gamblerId].LastMessageId;
if (lastMsgId != null)
{
_kfChatBot.ScheduleMessageAutoDelete(lastMsgId, TimeSpan.FromSeconds(15));
}
ActiveGames.Remove(gamblerId);
await SaveActiveGames(gamblerId);
}
@@ -337,7 +341,6 @@ public class KasinoMines
await _kfChatBot.SendChatMessageAsync(
$"{game.Creator.User.FormatUsername()}, you won {await payout.FormatKasinoCurrencyAsync()} from your {await game.Wager.FormatKasinoCurrencyAsync()} bet on mines, collecting {game.BetsPlaced.Count} gems while avoiding {game.Mines} mines. Net: {await net.FormatKasinoCurrencyAsync()}. Balance: {await newBalance.FormatKasinoCurrencyAsync()}", true, autoDeleteAfter: TimeSpan.FromSeconds(15));
await Task.Delay(TimeSpan.FromSeconds(15));
await RemoveGame(game.Creator.Id);
}