update globals

This commit is contained in:
Zack Rauen 2020-02-27 20:45:32 -05:00
parent f6613ca200
commit 86fe1b5e11
5 changed files with 70 additions and 90 deletions

File diff suppressed because one or more lines are too long

56
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -33,6 +33,9 @@ export const settings = {
"Scroll To Settings": {id: "fork-ps-3", info: "Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)", implemented: true, hidden: false, cat: "core", category: "content manager"},
"Automatic Loading": {id: "fork-ps-5", info: "Automatically loads, reloads, and unloads plugins and themes", implemented: true, hidden: false, cat: "core", category: "content manager"},
/* Donors */
"BBD Beta": {id: "fork-beta", info: "Gives access to BBD beta. (Requires full restart after changing.)", implemented: true, hidden: true, cat: "core", category: "donors"},
/* Developer */
"Developer Mode": {id: "bda-gs-8", info: "Developer Mode", implemented: true, hidden: false, cat: "core", category: "developer settings"},
"Copy Selector": {id: "fork-dm-1", info: "Adds a \"Copy Selector\" option to context menus when developer mode is active", implemented: true, hidden: false, cat: "core", category: "developer settings"},
@ -86,7 +89,8 @@ export const defaultCookie = {
"fork-es-2": false,
"fork-es-3": true,
"fork-wp-1": false,
"fork-wp-2": false
"fork-wp-2": false,
"fork-beta": true
};

View File

@ -3,45 +3,52 @@ import loadingIcon from "./loadingIcon";
localStorageFix();
loadingIcon();
import Core from "./core";
const deprecateGlobal = (key, value) => {
Object.defineProperty(window, key, {
get() {
Utils.warn("Deprecation Notice", `"${key}" may be removed in future versions. Please only use BdApi.`);
return value;
}
});
};
import * as Globals from "./0globals";
const globalKeys = Object.keys(Globals);
for (const key of globalKeys) deprecateGlobal(key, Globals[key]);
import BdApi from "./bdApi";
import BDV2 from "./v2";
import pluginModule from "./pluginModule";
import themeModule from "./themeModule";
import Utils from "./utils";
import BDEvents from "./bdEvents";
import settingsPanel from "./settingsPanel";
import DataStore from "./dataStore";
import emoteModule from "./emoteModule";
import ContentManager from "./contentManager";
import ClassNormalizer from "./classNormalizer";
deprecateGlobal("BDV2", BDV2);
deprecateGlobal("pluginModule", pluginModule);
deprecateGlobal("themeModule", themeModule);
deprecateGlobal("Utils", Utils);
deprecateGlobal("BDEvents", BDEvents);
deprecateGlobal("settingsPanel", settingsPanel);
deprecateGlobal("DataStore", DataStore);
deprecateGlobal("emoteModule", emoteModule);
deprecateGlobal("ContentManager", ContentManager);
deprecateGlobal("ClassNormalizer", ClassNormalizer);
window.BdApi = BdApi;
// DataStore
// BDEvents
// settingsPanel
// emoteModule
// quickEmoteMenu
// voiceMode
// pluginModule
// themeModule
// dMode
// publicServersModule
// minSupportedVersion
// bbdVersion
// bbdChangelog
// mainCore
// settings
// defaultCookie
// settingsCookie
// bdpluginErrors
// bdthemeErrors
// bdConfig
// bemotes
// Utils
// ContentManager
// pluginCookie
// themeCookie
// devMode
// ClassNormalizer
// BDV2
// localStorage
// bdEmotes
// bdEmoteSettingIDs
// bdthemes
// bdplugins
// emotePromise
import Core from "./core";
export default Core;
// function patchModuleLoad() {

View File

@ -120,6 +120,19 @@ export default new class V2_SettingsPanel {
// else $("body").removeClass("bd-blue");
// }
if (id == "fork-beta") {
try {
const fs = require("fs");
const path = require("path");
const configPath = path.join(DiscordNative.process.remote.resourcesPath, "app", "betterdiscord", "config.json");
const config = __non_webpack_require__(configPath);
if (enabled) config.branch = "modularize";
else config.branch = "master";
fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
}
catch (err) {console.error(err);}
}
if (id == "bda-gs-2") {
if (enabled) $("body").addClass("bd-minimal");
else $("body").removeClass("bd-minimal");
@ -198,6 +211,15 @@ export default new class V2_SettingsPanel {
}
async initializeSettings() {
const checkForBetaAccess = async () => {
const SortedGuildStore = BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"]);
const GuildMemberStore = BDV2.WebpackModules.findByUniqueProperties(["getMember"]);
const inServer = SortedGuildStore.getFlattenedGuildIds().includes("292141134614888448");
const userId = BDV2.UserStore.getCurrentUser().id;
const member = GuildMemberStore.getMember("292141134614888448", userId);
const hasRole = inServer && member ? member.roles.includes("452687773678436354") : false;
if (hasRole) settings["BBD Beta"].hidden = false;
};
// if (settingsCookie["bda-gs-b"]) $("body").addClass("bd-blue");
if (settingsCookie["bda-gs-2"]) $("body").addClass("bd-minimal");
@ -216,6 +238,7 @@ export default new class V2_SettingsPanel {
}
if (settingsCookie["bda-gs-8"]) dMode.enable(settingsCookie["fork-dm-1"]);
checkForBetaAccess();
this.saveSettings();
}