mirror of
https://github.com/barelyprofessional/KfChatDotNet.git
synced 2026-04-30 03:22:04 -04:00
Check if LastMessageId is its default value or not before attempting to delete
This commit is contained in:
@@ -3,9 +3,7 @@ using KfChatDotNetBot.Extensions;
|
||||
using KfChatDotNetBot.Models;
|
||||
using KfChatDotNetBot.Models.DbModels;
|
||||
using KfChatDotNetBot.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using NLog;
|
||||
using SixLabors.Fonts;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace KfChatDotNetBot.Services;
|
||||
@@ -41,7 +39,11 @@ public class KasinoMines
|
||||
public async Task ResetMessage(SentMessageTrackerModel msg)
|
||||
{
|
||||
_logger.Info("Resetting message");
|
||||
await _kfChatBot.KfClient.DeleteMessageAsync(LastMessageId);
|
||||
// 0 is the default for int
|
||||
if (LastMessageId != 0)
|
||||
{
|
||||
await _kfChatBot.KfClient.DeleteMessageAsync(LastMessageId);
|
||||
}
|
||||
if (msg.ChatMessageId == null) throw new InvalidOperationException($"ChatMessageId was null for {msg.Reference}");
|
||||
LastMessageId = msg.ChatMessageId.Value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user