Update RemoveBlockedUsers.plugin.js

This commit is contained in:
Mirco Wittrien 2023-04-16 11:08:32 +02:00
parent e4f50303c3
commit 6b9cc15a80
1 changed files with 8 additions and 8 deletions

View File

@ -2,7 +2,7 @@
* @name RemoveBlockedUsers
* @author DevilBro
* @authorId 278543574059057154
* @version 1.6.2
* @version 1.6.3
* @description Removes blocked Messages/Users
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -168,25 +168,25 @@ module.exports = (_ => {
let muteTimeout;
let channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
let connectedUsers = [BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId())[channelId]].flat().filter(n => n && n.voiceState && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.voiceState.userId));
let oldUnblockedConnectedUsers = [BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId())[channelId]].flat().filter(n => n && n.user && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.SoundUtils, "playSound", {before: e => {
let type = e.methodArguments[0];
if (!this.settings.notifications.voiceChat || !["disconnect", "user_join", "user_leave", "user_moved"].includes(type)) return;
channelId = BDFDB.LibraryModules.RTCConnectionUtils.getChannelId();
if (channelId) {
let allConnectedUsers = [BDFDB.LibraryStores.SortedVoiceStateStore.getVoiceStates(BDFDB.LibraryModules.RTCConnectionUtils.getGuildId())[channelId]].flat();
let unblockedUsers = allConnectedUsers.filter(n => n && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId));
let unmutedBlockedUsers = allConnectedUsers.filter(n => n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.userId) && !BDFDB.LibraryStores.MediaEngineStore.isLocalMute(n.userId));
let unblockedUsers = allConnectedUsers.filter(n => n && !BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id));
let unmutedBlockedUsers = allConnectedUsers.filter(n => n && BDFDB.LibraryStores.RelationshipStore.isBlocked(n.user.id) && !BDFDB.LibraryStores.MediaEngineStore.isLocalMute(n.userId));
if (unmutedBlockedUsers.length) {
BDFDB.TimeUtils.clear(muteTimeout);
muteTimeout = BDFDB.TimeUtils.timeout(_ => {
while (unmutedBlockedUsers.length) BDFDB.LibraryModules.MediaEngineUtils.toggleLocalMute(unmutedBlockedUsers.pop().userId);
while (unmutedBlockedUsers.length) BDFDB.LibraryModules.MediaEngineUtils.toggleLocalMute(unmutedBlockedUsers.pop().user.id);
}, 1000);
}
if (unblockedUsers.length != connectedUsers.length) e.methodArguments[1] = 0;
connectedUsers = unblockedUsers;
if (unblockedUsers.length == oldUnblockedConnectedUsers.length) e.methodArguments[1] = 0;
oldUnblockedConnectedUsers = unblockedUsers;
}
else connectedUsers = [];
else oldUnblockedConnectedUsers = [];
}});
BDFDB.DiscordUtils.rerenderAll();