Also cache bot messages

This commit is contained in:
Noi 2022-12-03 17:21:42 -08:00
parent 12f8359b90
commit fc8826b37f

View file

@ -21,7 +21,11 @@ class MessageCachingSubservice {
} }
private async Task AddOrUpdateCacheItemAsync(SocketMessage arg, bool isUpdate) { private async Task AddOrUpdateCacheItemAsync(SocketMessage arg, bool isUpdate) {
if (!Common.Utilities.IsValidUserMessage(arg, out _)) return; //if (!Common.Utilities.IsValidUserMessage(arg, out _)) return;
if (arg.Channel is not SocketTextChannel) return;
if (arg.Author.IsWebhook) return; // do get bot messages, don't get webhooks
if (((IMessage)arg).Type != MessageType.Default) return;
if (arg is SocketSystemMessage) return;
using var db = new BotDatabaseContext(); using var db = new BotDatabaseContext();
CachedGuildMessage? cachedMsg = db.GuildMessageCache.Where(m => m.MessageId == (long)arg.Id).SingleOrDefault(); CachedGuildMessage? cachedMsg = db.GuildMessageCache.Where(m => m.MessageId == (long)arg.Id).SingleOrDefault();