update some checks

This commit is contained in:
Zack Rauen 2020-03-14 21:31:05 -04:00
parent 5576d2c150
commit ad7cd97cf2
5 changed files with 65 additions and 13 deletions

File diff suppressed because one or more lines are too long

2
js/main.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,12 +1,12 @@
// var settingsPanel, emoteModule, quickEmoteMenu, voiceMode, pluginModule, themeModule, dMode, publicServersModule, mainCore, BDV2;
export const minSupportedVersion = "0.3.0";
export const bbdVersion = "0.2.24";
export const bbdVersion = "0.2.25-beta";
export const bbdChangelog = {
description: "Mostly behind the scenes changes here.",
description: "Mostly behind the scenes changes again.",
changes: [
{title: "What's New?", items: ["**Dark Mode is back!** Or rather... it's toggleable again and no longer forced on.", "**Changes for developers!** Plugin and theme developers will now have more options to customize their plugin cards in their METAs and also a new META structure."]},
{title: "Fixes", type: "fixed", items: ["**Emote Menu** should now show both Twich Global emotes and your favorites, you should even be able to click on them again!"]},
{title: "Minor Stuff", type: "improved", items: ["**Clean Code.** Well not really. But BD's code is starting to be cleaned up to make it easier to maintain and better performing."]}
{title: "What's New?", items: ["**Changes for plugin developers!** There are some new items in the `BdApi` that you may want to check out."]},
{title: "Fixes", type: "fixed", items: ["**Modal Footers** are no longer blank hopefully!"]},
{title: "Minor Stuff", type: "improved", items: ["**Injector Version** is now included in the version list to try and quell the confusion."]}
]
};
@ -33,8 +33,8 @@ 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"},
/* Beta */
"BBD Beta": {id: "fork-beta", info: "Gives access to BBD beta. (Requires full restart after changing.)", implemented: true, hidden: false, cat: "core", category: "beta"},
/* Developer */
"Developer Mode": {id: "bda-gs-8", info: "Developer Mode", implemented: true, hidden: false, cat: "core", category: "developer settings"},

View File

@ -42,6 +42,26 @@ Core.prototype.init = async function() {
`);
}
const SortedGuildStore = BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"]);
const GuildMemberStore = BDV2.WebpackModules.findByUniqueProperties(["getMember"]);
const userId = BDV2.UserStore.getCurrentUser().id;
const checkForRole = async (serverId, roleId) => {
if (!SortedGuildStore || !GuildMemberStore) return false;
const hasServer = SortedGuildStore.getFlattenedGuildIds().includes(serverId);
const member = GuildMemberStore.getMember(serverId, userId);
return (hasServer && member ? member.roles.includes(roleId) : false);
};
const checkForBetaAccess = async () => {
if (userId === "197435711476072449") return false;
const isDonor = checkForRole("292141134614888448", "452687773678436354");
const isPluginDev = checkForRole("86004744966914048", "125166040689803264") || checkForRole("280806472928198656", "357242595950329857");
return (isDonor || isPluginDev);
};
const shouldHaveBeta = checkForBetaAccess();
if (!shouldHaveBeta) {
Utils.alert("Beta Access", `You don't seem like you should have Beta Access... how did you get here?`);
}
Utils.log("Startup", "Initializing Settings");
this.initSettings();
// emoteModule = new EmoteModule();
@ -261,10 +281,12 @@ Core.prototype.patchSocial = function() {
const BBDLink = BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://twitter.com/BandagedBD", title: "BandagedBD", target: "_blank"}, "BandagedBD");
const AuthorLink = BDV2.React.createElement(Anchor, {className: "bd-social-link", href: "https://twitter.com/ZackRauen", title: "Zerebos", target: "_blank"}, "Zerebos");
const additional = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, [BBDLink, ` ${bbdVersion} by `, AuthorLink]);
const injector = BDV2.react.createElement("div", {className: "colorMuted-HdFt4q size12-3cLvbJ"}, ["BBD Injector", ` ${bbdVersion} by `, AuthorLink]);
const originalVersions = children[children.length - 1].type;
children[children.length - 1].type = function() {
const returnVal = originalVersions(...arguments);
returnVal.props.children.push(injector);
returnVal.props.children.push(additional);
return returnVal;
};

View File

@ -73,12 +73,30 @@ export default new class V2_SettingsPanel {
return this.getSettings("emote");
}
getSettings(category) {
const SortedGuildStore = BDV2.WebpackModules.findByUniqueProperties(["getSortedGuilds"]);
const GuildMemberStore = BDV2.WebpackModules.findByUniqueProperties(["getMember"]);
const userId = BDV2.UserStore.getCurrentUser().id;
const checkForRole = async (serverId, roleId) => {
if (!SortedGuildStore || !GuildMemberStore) return false;
const hasServer = SortedGuildStore.getFlattenedGuildIds().includes(serverId);
const member = GuildMemberStore.getMember(serverId, userId);
return (hasServer && member ? member.roles.includes(roleId) : false);
};
const checkForBetaAccess = async () => {
if (userId === "197435711476072449") return false;
const isDonor = checkForRole("292141134614888448", "452687773678436354");
const isPluginDev = checkForRole("86004744966914048", "125166040689803264") || checkForRole("280806472928198656", "357242595950329857");
return (isDonor || isPluginDev);
};
const shouldHaveBeta = checkForBetaAccess();
return Object.keys(settings).reduce((arr, key) => {
const setting = settings[key];
if (setting.cat === category && setting.implemented && !setting.hidden) {
if (settings.category !== "beta" || (settings.category === "beta" && shouldHaveBeta)) {
setting.text = key;
arr.push(setting);
}
}
return arr;
}, []);
}
@ -137,6 +155,18 @@ export default new class V2_SettingsPanel {
fs.writeFileSync(configPath, JSON.stringify(config, null, 4));
}
catch (err) {console.error(err);}
(() => {
const ModalStack = BDV2.WebpackModules.findByUniqueProperties(["push", "update", "pop", "popWithKey"]);
const AlertModal = BDV2.WebpackModules.findByPrototypes(["handleCancel", "handleSubmit", "handleMinorConfirm"]);
if (!ModalStack || !AlertModal) return;
ModalStack.push(function(props) {
return BDV2.React.createElement(AlertModal, Object.assign({
title: "Restart Required",
body: "Please FULLY restart Discord in order for these changes to take effect.",
}, props));
});
})();
}
if (id == "bda-gs-2") {