``` return class ToggleVoice extends Plugin { onStart() { this.keybind = BdApi.loadData(config.info.name, "keybind") ?? []; this.showToast = BdApi.loadData(config.info.name, "showToast") ?? true; this.listener = this.listener.bind(this); document.addEventListener('keydown', this.listener); document.addEventListener('keyup', this.listener); } onStop() { document.removeEventListener("keydown", this.listener); document.removeEventListener("keyup", this.listener); } toogleVoiceMode() { const currentMode = WebpackModules.getByProps("getVoiceSettings").getVoiceSettings().input_mode.type; let mode = currentMode !== "VOICE_ACTIVITY" ? "VOICE_ACTIVITY" : "PUSH_TO_TALK"; BdApi.findModuleByProps('toggleSelfDeaf').setMode(mode); if (this.showToast) BdApi.showToast(`Set to ${mode == "VOICE_ACTIVITY" ? "Voice Activity" : "PTT"}`, { icon: true, timeout: 500, type: 'success' }) } listener(e) { if (!this.keybind.length) return; var map = {}; e = e || event; // to deal with IE map[e.keyCode] = e.type == 'keydown'; let work = () => { for (const e of this.keybind) { let key = e; if (!map[key]) return false; } return true; } work = work(); if (work) { this.toogleVoiceMode(); } } getSettingsPanel() { return Settings.SettingPanel.build(this.saveSettings.bind(this), new Settings.Keybind("Keybind", "Keybind to toogle between voice activity and ptt.", this.keybind, (e) => { this.keybind = e; }), new Settings.Switch("Popup/Toast", "Display message Hidden popup", this.showToast, (e) => { this.showToast = e; })) } saveSettings() { BdApi.saveData(config.info.name, "keybind", this.keybind); BdApi.saveData(config.info.name, "showToast", this.showToast); } }```