import {SettingsCookie} from "data"; import {BDV2, DiscordModules} from "modules"; import {PublicServers} from "ui"; export default new class { initialize() { const wrapper = BDV2.guildClasses.wrapper.split(" ")[0]; const guilds = $(`.${wrapper} .scroller-2FKFPG >:first-child`); guilds.after(this.button); } get component() { return DiscordModules.React.createElement(PublicServers.Layer, { rootId: "pubslayerroot", id: "pubslayer", children: DiscordModules.React.createElement(PublicServers.Menu, {rootId: "pubslayerroot"}) }); } get root() { const _root = document.getElementById("pubslayerroot"); if (!_root) { if (!this.injectRoot()) return null; return this.root; } return _root; } injectRoot() { if (!$(".layers, .layers-3iHuyZ").length) return false; $(".layers, .layers-3iHuyZ").append($("
", { id: "pubslayerroot" })); return true; } render() { // BdApi.alert("Broken", "Sorry but the Public Servers modules is currently broken, I recommend disabling this feature for now."); const root = this.root; if (!root) { console.log("FAILED TO LOCATE ROOT: .layers"); return; } DiscordModules.ReactDOM.render(this.component, root); } get button() { const btn = $("", { "class": BDV2.guildClasses.listItem, "id": "bd-pub-li", "style": SettingsCookie["bda-gs-1"] ? "" : "display: none;" }).append($("", { "class": "wrapper-25eVIn " + BDV2.guildClasses.circleButtonMask, "text": "public", "id": "bd-pub-button", "click": () => { this.render(); } })); return btn; } };