calamity icon indicating copy to clipboard operation
calamity copied to clipboard

Sequencing of events?

Open MorrowM opened this issue 3 years ago • 1 comments

This is more of a question than an issue, but is there a way to figure out which event occurred first between two events?

My use-case is that I have a bot that sends join and leave messages into a text channel whenever someone joins or leaves an associated voice channel. I have a handler which reacts to VoiceStateUpdateEvts and sends the appropriate message. The issue is that sometimes someone joins and immediately leaves a voice channel (or vice-versa). When that occurs it can sometimes happen that the leave event is handled before the join event which means the messages are sent out of order.

So my question is whether there's a way to recover such ordering information. From the Discord API I see there's some sort of sequence number but I'm not sure whether that's suitable for this.

MorrowM avatar Oct 07 '22 20:10 MorrowM

We could definitely add something to the event handler context to include the sequence number, though I really wouldn't be surprised if discord is sending the events out of order to begin with. The only point of parallelism in event handling is each event handling running in its own thread, internal library event handling is sequential until that point.

simmsb avatar Oct 07 '22 21:10 simmsb