try to fix some errors I noticed in logs

This commit is contained in:
13xforever 2022-07-04 16:11:12 +05:00
parent 42fdd9556b
commit fd0c730f81
3 changed files with 17 additions and 14 deletions

View File

@ -133,18 +133,21 @@ internal static class ContentFilter
#endif
var content = new StringBuilder(message.Content);
foreach (var attachment in message.Attachments)
content.AppendLine(attachment.FileName);
foreach (var embed in message.Embeds)
{
content.AppendLine(embed.Title)
.AppendLine(embed.Description);
foreach (var field in embed.Fields)
if (message.Attachments is not null)
foreach (var attachment in message.Attachments.Where(a => a is not null))
content.AppendLine(attachment.FileName);
if (message.Embeds is not null)
foreach (var embed in message.Embeds.Where(e => e is not null))
{
content.AppendLine(field.Name);
content.AppendLine(field.Value);
content.AppendLine(embed.Title)
.AppendLine(embed.Description);
if (embed.Fields is not null)
foreach (var field in embed.Fields.Where(f => f is not null))
{
content.AppendLine(field.Name);
content.AppendLine(field.Value);
}
}
}
var trigger = await FindTriggerAsync(FilterContext.Chat, content.ToString()).ConfigureAwait(false);
if (trigger == null)
return true;

View File

@ -78,7 +78,7 @@ internal static class DiscordInviteFilter
}
catch (Exception e)
{
Config.Log.Warn($"Some missing permissions in #{channel.Name}: {e.Message}");
Config.Log.Warn(e, $"Some missing permissions in #{channel.Name}");
}
}
}

View File

@ -27,7 +27,7 @@ internal static class GlobalMessageCache
lock (MessageQueue)
{
if (!MessageQueue.TryGetValue(args.Channel.Id, out queue))
MessageQueue[args.Channel.Id] = queue = new FixedLengthBuffer<ulong, DiscordMessage>(KeyGen);
MessageQueue[args.Channel.Id] = queue = new(KeyGen);
}
lock(queue.SyncObj)
queue.Add(args.Message);
@ -83,7 +83,7 @@ internal static class GlobalMessageCache
if (!MessageQueue.TryGetValue(ch.Id, out var queue))
lock (MessageQueue)
if (!MessageQueue.TryGetValue(ch.Id, out queue))
MessageQueue[ch.Id] = queue = new FixedLengthBuffer<ulong, DiscordMessage>(KeyGen);
MessageQueue[ch.Id] = queue = new(KeyGen);
List<DiscordMessage> result;
lock(queue.SyncObj)
result = queue.Reverse().Take(count).ToList();
@ -114,7 +114,7 @@ internal static class GlobalMessageCache
if (!MessageQueue.TryGetValue(ch.Id, out var queue))
lock (MessageQueue)
if (!MessageQueue.TryGetValue(ch.Id, out queue))
MessageQueue[ch.Id] = queue = new FixedLengthBuffer<ulong, DiscordMessage>(KeyGen);
MessageQueue[ch.Id] = queue = new(KeyGen);
List<DiscordMessage> result;
lock(queue.SyncObj)
result = queue.Reverse().SkipWhile(m => m.Id >= msgId).Take(count).ToList();