Skip to content

Commit

Permalink
Remove settings and add default delay
Browse files Browse the repository at this point in the history
  • Loading branch information
damsdev1 committed Mar 14, 2023
1 parent fb9d00b commit 9454f36
Showing 1 changed file with 7 additions and 31 deletions.
38 changes: 7 additions & 31 deletions src/plugins/voiceChatUtilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,25 @@ import definePlugin, { OptionType } from "@utils/types";
import { findByProps, findStoreLazy } from "@webpack";
import { Menu, RestAPI, UserStore } from "@webpack/common";

const settings = definePluginSettings({
delay: {
description: "Bulk Actions delay (milliseconds)",
type: OptionType.NUMBER,
default: 0,
stickToMarkers: true,
}
});

const VoiceStateStore = findStoreLazy("VoiceStateStore");


function sendPatch(channel, body, bypass = false) {
const usersVoice = VoiceStateStore.getVoiceStatesForChannel(channel.id); // Get voice states by channel id
const myId = UserStore.getCurrentUser().id; // Get my user id

if (settings.store.delay === 0) {
Object.keys(usersVoice).forEach(function (key) {
const userVoice = usersVoice[key];
Object.keys(usersVoice).forEach(function (key, index) {
const userVoice = usersVoice[key];

if (bypass || userVoice.userId !== myId) {
if (bypass || userVoice.userId !== myId) {
setTimeout(() => {
RestAPI.patch({
url: `/guilds/${channel.guild_id}/members/${userVoice.userId}`,
body: body
});
}
});
} else {
Object.keys(usersVoice).forEach(function (key, index) {
const userVoice = usersVoice[key];

if (bypass || userVoice.userId !== myId) {
setTimeout(() => {
RestAPI.patch({
url: `/guilds/${channel.guild_id}/members/${userVoice.userId}`,
body: body
});
}, index * settings.store.delay);
}
});
}

}, index * 500);
}
});
}

const voiceChannelContextMenuPatch: NavContextMenuPatchCallback = (children, args) => {
Expand Down Expand Up @@ -171,7 +148,6 @@ export default definePlugin({
}

],
settings,
patches: [],
// Delete these two below if you are only using code patches
start() {
Expand Down

0 comments on commit 9454f36

Please sign in to comment.