Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve voice state event selection logic #395

Closed
wants to merge 0 commits into from
Closed

Improve voice state event selection logic #395

wants to merge 0 commits into from

Conversation

tombuente
Copy link

@tombuente tombuente commented Sep 25, 2024

First, we verify if the old state is valid and whether its channel ID is not nil. This indicates that the user has left a voice channel. Next, we check if the event includes a new channel ID. This indicates that the user has joined a new voice channel.
oldOk && oldVoiceState.ChannelID != nil && event.ChannelID != nil

The first part ((oldOk || oldVoiceState.ChannelID == nil)) of the next comparison is redundant. We already confirmed whether a move took place, so if the event's channel ID is not nil, it must be a join.

In my opinion the last comparison is flawed. We don't really check whether there was an old voice state. If the old state is invalid, we have not left a channel. According to the old logic, a leave still takes place, even if only the new channel ID is not equal to nil.

@tombuente tombuente closed this Sep 25, 2024
@tombuente tombuente reopened this Sep 25, 2024
@tombuente tombuente closed this Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant