Drop consecutive duplicate messages from the gateway
This commit is contained in:
parent
cde495cd3a
commit
356fb76cb2
@ -48,6 +48,12 @@ namespace PluralKit.Bot
|
|||||||
|
|
||||||
public async Task Handle(MessageCreateEventArgs evt)
|
public async Task Handle(MessageCreateEventArgs evt)
|
||||||
{
|
{
|
||||||
|
// Drop the message if we've already received it.
|
||||||
|
// Gateway occasionally resends events for whatever reason and it can break stuff relying on IDs being unique
|
||||||
|
// Not a perfect fix since reordering could still break things but... it's good enough for now
|
||||||
|
// (was considering checking the order of the IDs but IDs aren't guaranteed to be *perfectly* in order, so that'd cause false positives)
|
||||||
|
// LastMessageCache is updated in RegisterMessageMetrics so the ordering here is correct.
|
||||||
|
if (_lastMessageCache.GetLastMessage(evt.Channel.Id) == evt.Message.Id) return;
|
||||||
RegisterMessageMetrics(evt);
|
RegisterMessageMetrics(evt);
|
||||||
|
|
||||||
// Ignore system messages (member joined, message pinned, etc)
|
// Ignore system messages (member joined, message pinned, etc)
|
||||||
|
Loading…
Reference in New Issue
Block a user