🧩
Plugin

DisableDMCallIdle

von HeadX

Verhindert automatisches Kicken aus DM-Voice-Calls nach 3 Minuten Inaktivität. Funktioniert ohne ZeresPluginLibrary.

🏷️ v2.0.2 📦 8.0 KB 🗓️ 2.7.2026 📄 193 Zeilen
⬇️ Download 📄 Raw ansehen 🌐 Source
Installation: Datei herunterladen und in deinen BetterDiscord-Ordner legen — %appdata%\\BetterDiscord\\plugins (Windows) bzw. über Discord: Einstellungen → Plugins → Plugin-Ordner öffnen.
DisableDMCallIdle.plugin.js · 193 Zeilen · 8.0 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
/*
  FILE META START
  name: DisableDMCallIdle.plugin.js
  version: 0.0.10
  description: Multi-surface admin, cloud, bot host, login, and secure chat server.
  lastModified: 2026-05-04T20:22:59.634Z
  checksum: 8cb47c7926f036620463b01f32cee44b325345cf986a20d7a7c5fb8e5aeed493
  FILE META END
*/

/**
 * @name DisableDMCallIdle
 * @author HeadX
 * @authorId 808385710700494919
 * @description Verhindert automatisches Kicken aus DM-Voice-Calls nach 3 Minuten Inaktivität. Funktioniert ohne ZeresPluginLibrary.
 * @version 2.0.2
 * @invite J6wTJJ5fp
 * @website https://headcraft.cloud/better-discord
 * @source https://headcraft.cloud/better-discord/DisableDMCallIdle.plugin.js
 * @updateUrl https://headcraft.cloud/better-discord/DisableDMCallIdle.plugin.js
 */



const { Webpack, Data } = BdApi;

module.exports = class DisableDMCallIdle {
    constructor() {
        this.name = "DisableDMCallIdle";
        this.patches = [];
        this.blockedTimers = 0;
        this.settings = {
            showNotifications: true,
            disableForServerCalls: false
        };
    }

    loadSettings() {
        const saved = Data.load(this.name, "settings");
        this.settings = saved ? { ...this.settings, ...saved } : this.settings;
    }

    saveSettings() {
        Data.save(this.name, "settings", this.settings);
    }

    start() {
        this.loadSettings();
        this.blockedTimers = 0;
        
        try {
            this.patchDispatcher();
            
            if (this.settings.showNotifications) {
                BdApi.showToast("DisableDMCallIdle aktiviert", { type: "success" });
            }
            
            console.log("[DisableDMCallIdle] Plugin erfolgreich gestartet");
            this._autoUpdate();
        } catch (err) {
            console.error("[DisableDMCallIdle] Fehler beim Starten:", err);
            BdApi.showToast("DisableDMCallIdle: Fehler - siehe Konsole", { type: "error" });
        }
    }

    patchDispatcher() {
        const Dispatcher = Webpack.getByKeys("dispatch", "subscribe") || 
                          Webpack.getByKeys("dispatch", "register") ||
                          Webpack.getStore("Dispatcher");
        if (!Dispatcher) {
            console.warn("[DisableDMCallIdle] Dispatcher nicht gefunden - versuche alternativen Ansatz");
            // Fallback: Subscribe to Flux dispatcher via BdApi
            try {
                const FluxDispatcher = BdApi.Webpack.getModule(m => m?.dispatch && m?.subscribe && m?._dispatch);
                if (FluxDispatcher) {
                    this._patchDispatcherInternal(FluxDispatcher);
                    return;
                }
            } catch(e) {}
            console.error("[DisableDMCallIdle] Kein Dispatcher gefunden - Plugin kann Idle-Events nicht blockieren");
            return;
        }

        this._patchDispatcherInternal(Dispatcher);
    }

    _patchDispatcherInternal(Dispatcher) {
        const originalDispatch = Dispatcher.dispatch.bind(Dispatcher);
        const self = this;
        
        Dispatcher.dispatch = function(event) {
            if (event?.type === "RTC_CONNECTION_IDLE" || 
                event?.type === "CALL_IDLE_DISCONNECT" ||
                event?.type === "BOT_CALL_IDLE_DISCONNECT") {
                console.log("[DisableDMCallIdle] Idle-Event blockiert:", event.type);
                self.blockedTimers++;
                return;
            }
            return originalDispatch(event);
        };

        this.patches.push(() => {
            Dispatcher.dispatch = originalDispatch;
        });
    }

    stop() {
        this.patches.forEach(unpatch => {
            try {
                unpatch();
            } catch (err) {
                console.error("[DisableDMCallIdle] Fehler beim Entpatchen:", err);
            }
        });
        this.patches = [];

        if (this.settings.showNotifications) {
            BdApi.showToast(`DisableDMCallIdle deaktiviert (${this.blockedTimers} Timer blockiert)`, { type: "info" });
        }
        
        console.log("[DisableDMCallIdle] Plugin gestoppt");
    }

    getSettingsPanel() {
        const panel = document.createElement("div");
        panel.style.padding = "10px";
        panel.style.color = "var(--text-normal)";

        const settings = [
            { key: "showNotifications", label: "Benachrichtigungen anzeigen" },
            { key: "disableForServerCalls", label: "Auch für Server-Calls deaktivieren" }
        ];

        settings.forEach(setting => {
            const container = document.createElement("div");
            container.style.marginBottom = "15px";
            container.style.display = "flex";
            container.style.justifyContent = "space-between";
            container.style.alignItems = "center";

            const label = document.createElement("span");
            label.textContent = setting.label;
            container.appendChild(label);

            const toggle = document.createElement("input");
            toggle.type = "checkbox";
            toggle.checked = this.settings[setting.key];
            toggle.style.cursor = "pointer";
            toggle.addEventListener("change", () => {
                this.settings[setting.key] = toggle.checked;
                this.saveSettings();
            });
            container.appendChild(toggle);

            panel.appendChild(container);
        });

        const stats = document.createElement("p");
        stats.textContent = `Blockierte Timer in dieser Session: ${this.blockedTimers}`;
        stats.style.marginTop = "20px";
        stats.style.color = "var(--text-muted)";
        panel.appendChild(stats);

        return panel;
    }

    // ===== HeadX Auto-Update System =====
    async _autoUpdate() {
        const pluginName = this.name || "DisableDMCallIdle";
        const currentVersion = this.version || this.meta?.version || "0.0.0";
        const updateUrl = this.updateUrl || this.meta?.updateUrl || `https://headcraft.cloud/better-discord/${pluginName}.plugin.js`;
        try {
            const fs = require("fs"), path = require("path");
            let res; try { res = await fetch(updateUrl); } catch(e) {}
            if (!res?.ok) { try { res = await BdApi.Net.fetch(updateUrl); } catch(e) {} }
            if (!res?.ok) return;
            const remoteCode = await res.text();
            const remoteVersion = remoteCode.match(/@version\s+([^\n\r]+)/)?.[1]?.trim();
            if (!remoteVersion) return;
            const compare = (a, b) => { const pa = a.split('.').map(Number), pb = b.split('.').map(Number); for (let i = 0; i < Math.max(pa.length, pb.length); i++) { if ((pa[i]||0) > (pb[i]||0)) return 1; if ((pa[i]||0) < (pb[i]||0)) return -1; } return 0; };
            if (compare(remoteVersion, currentVersion) <= 0) return;
            console.log(`[${pluginName}] Update verfügbar: ${currentVersion} → ${remoteVersion}`);
            const pluginsFolder = BdApi.Plugins.folder;
            const allFiles = fs.readdirSync(pluginsFolder);
            const pluginFile = allFiles.find(f => f.endsWith('.plugin.js') && fs.readFileSync(path.join(pluginsFolder, f), 'utf8').match(new RegExp(`@name\\s+${pluginName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\s`))) || `${pluginName}.plugin.js`;
            const filePath = path.join(pluginsFolder, pluginFile);
            if (typeof BdApi.UI?.showNotification === 'function') {
                BdApi.UI.showNotification({ title: `${pluginName} Update`, content: `Version ${remoteVersion} ist verfügbar! (Aktuell: ${currentVersion})`, actions: [{ label: "Jetzt updaten", onClick: () => { fs.writeFileSync(filePath, remoteCode, 'utf8'); BdApi.showToast(`${pluginName} auf v${remoteVersion} aktualisiert!`, { type: "success" }); } }] });
            } else { BdApi.showToast(`${pluginName}: Update v${remoteVersion} verfügbar!`, { type: "warning" }); }
        } catch (err) { console.error(`[${pluginName}] Auto-Update Fehler:`, err); }
    }
    // ===== Ende HeadX Auto-Update System =====
};
← Alle Plugins & Themes index.json headcraft.cloud