Faster muting/deafening at stage change #50
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is an issue regarding lags during the transition between game stages: #48
I too, can see, that sometimes it takes a while for the bot to mute/unmute everyone one by one.
Looking at the code, this is the reason for such "lag":
The bot always waits for one user to be muted until he initiates the muting of the next user.
I can totally see, why you did this, because of the sorted array. You don't want dead players to shortly be able to talk in discussion. To achieve that, you always first muted users one by one, and then unmuted other users one by one.
First of all: the
await
here did not have any effect, becausethis.updatePlayerMute(player)
andUtils.editMember()
didn't even return a Promise.That's fixed now.
So to be honest, I am not sure, whether this really speeds up the transition, but see for yourself:
Also there is a faster way to do so:
Using the
Promise.all()
feature in ES6 (no problem with Node.js 12) it is possible to first mute(and deafen) all players, that have to be muted, at once, wait for all of those to finish, and then unmute everyone else.This way, the bot doesn't have to wait 10 times (for a full round), but only 2 times.
Because of the waiting (not for a timeout, but for everyone to be muted) in between, it is still guaranteed, that no voice is leaked to people not supposed to hear it.