cs-codex-dist-tests/Tools/BiblioTech/Rewards/ChainEventsSender.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2024-06-27 08:14:23 +00:00
using Discord.WebSocket;
using Logging;
namespace BiblioTech.Rewards
{
public class ChainEventsSender
{
private readonly ILog log;
private SocketTextChannel? eventsChannel;
public ChainEventsSender(ILog log, SocketTextChannel? eventsChannel)
{
this.log = log;
this.eventsChannel = eventsChannel;
}
public async Task ProcessChainEvents(string[] eventsOverview)
{
if (eventsChannel == null || eventsOverview == null || !eventsOverview.Any()) return;
try
{
await Task.Run(async () =>
{
foreach (var e in eventsOverview)
{
if (!string.IsNullOrEmpty(e))
{
await eventsChannel.SendMessageAsync(e);
await Task.Delay(3000);
}
}
});
}
catch (Exception ex)
{
log.Error("Failed to process chain events: " + ex);
}
}
}
}