Fix Discord merging webhook messages with same username

Closes #33.
This commit is contained in:
spiral
2021-08-03 13:44:22 -04:00
parent c691adf8c9
commit 25f96dd920
3 changed files with 102 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Myriad.Gateway;
@@ -17,11 +18,13 @@ namespace PluralKit.Bot
private readonly IDatabase _db;
private readonly ModelRepository _repo;
private readonly ILogger _logger;
private readonly LastMessageCacheService _lastMessage;
public MessageDeleted(ILogger logger, IDatabase db, ModelRepository repo)
public MessageDeleted(ILogger logger, IDatabase db, ModelRepository repo, LastMessageCacheService lastMessage)
{
_db = db;
_repo = repo;
_lastMessage = lastMessage;
_logger = logger.ForContext<MessageDeleted>();
}
@@ -36,6 +39,8 @@ namespace PluralKit.Bot
await _db.Execute(c => _repo.DeleteMessage(c, evt.Id));
}
_lastMessage.HandleMessageDeletion(evt.ChannelId, evt.Id);
// Fork a task to delete the message after a short delay
// to allow for lookups to happen for a little while after deletion
_ = Inner();
@@ -54,6 +59,7 @@ namespace PluralKit.Bot
await _db.Execute(c => _repo.DeleteMessagesBulk(c, evt.Ids));
}
_lastMessage.HandleMessageDeletion(evt.ChannelId, evt.Ids.ToList());
_ = Inner();
return Task.CompletedTask;
}