Avoid deleting messages from the store if they're not webhooks

This commit is contained in:
Ske 2019-08-12 03:51:54 +02:00
parent 423d23faf7
commit aa04d2055e
2 changed files with 5 additions and 1 deletions

View File

@ -80,7 +80,7 @@ namespace PluralKit.Bot
.AddSingleton<IDiscordClient, DiscordShardedClient>(_ => new DiscordShardedClient(new DiscordSocketConfig
{
MessageCacheSize = 0,
MessageCacheSize = 10,
ExclusiveBulkDelete = true
}))
.AddSingleton<Bot>()

View File

@ -273,6 +273,10 @@ namespace PluralKit.Bot
public async Task HandleMessageDeletedAsync(Cacheable<IMessage, ulong> message, ISocketMessageChannel channel)
{
// Don't delete messages from the store if they aren't webhooks
// Non-webhook messages will never be stored anyway.
// If we're not sure (eg. message outside of cache), delete just to be sure.
if (message.HasValue && !message.Value.Author.IsWebhook) return;
await _messageStorage.Delete(message.Id);
}