feat: guild ban add/remove logging, store banned systems in database

This commit is contained in:
sam 2024-10-13 14:58:44 +02:00
parent ca99bdfb94
commit 8e030acaf3
12 changed files with 227 additions and 36 deletions

View file

@ -32,6 +32,10 @@ public class WebhookExecutorService(
private readonly ConcurrentDictionary<ulong, Timer> _timers = new();
private IUser? _selfUser;
/// <summary>
/// Sets the current user for this webhook executor service. This must be called as soon as possible,
/// before any logs are sent, such as in a READY event.
/// </summary>
public void SetSelfUser(IUser user) => _selfUser = user;
/// <summary>
@ -67,7 +71,7 @@ public class WebhookExecutorService(
/// Sends multiple embeds and/or files to a channel, bypassing the embed queue.
/// </summary>
/// <param name="channelId">The channel ID to send the content to.</param>
/// <param name="embeds">The embeds to send. Must be under 6000 characters in length total, this is not checked by this method.</param>
/// <param name="embeds">The embeds to send. Must be under 6000 characters in length total.</param>
/// <param name="files">The files to send.</param>
public async Task SendLogAsync(
ulong channelId,
@ -90,6 +94,14 @@ public class WebhookExecutorService(
return;
}
if (embeds.Select(e => e.TextLength()).Sum() > MaxContentLength)
{
_logger.Error(
"SendLogAsync was called with embeds totaling more than 6000 characters, bailing to prevent a bad request error"
);
return;
}
_logger.Debug(
"Sending {EmbedCount} embeds/{FileCount} files to channel {ChannelId}",
embeds.Count,