use superior library downloader
This commit is contained in:
parent
cd52105f1a
commit
eb62419b92
|
@ -429,58 +429,106 @@ var BetterUnavailableGuilds = (() => {
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
class TempErrorBoundary extends BdApi.React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
componentDidCatch(err, inf) {
|
||||||
|
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`);
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
if (typeof this.props.onError === 'function') this.props.onError(err);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let modalId;
|
||||||
|
const onHeckWouldYouLookAtThat = (() => {
|
||||||
|
if (!global.pluginModule || !global.BDEvents) return;
|
||||||
|
if (XenoLibMissing) {
|
||||||
|
const listener = () => {
|
||||||
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
|
return () => BDEvents.off('xenolib-loaded', listener);
|
||||||
|
} else {
|
||||||
|
const onLoaded = e => {
|
||||||
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
|
return () => BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
modalId = ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
TempErrorBoundary,
|
||||||
Object.assign(
|
{
|
||||||
{
|
label: 'missing dependency modal',
|
||||||
header,
|
onError: () => {
|
||||||
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
ModalStack.popWithKey(modalId); /* smh... */
|
||||||
red: false,
|
onFail();
|
||||||
confirmText: 'Download Now',
|
}
|
||||||
cancelText: 'Cancel',
|
},
|
||||||
onConfirm: () => {
|
BdApi.React.createElement(
|
||||||
const request = require('request');
|
ConfirmationModal,
|
||||||
const fs = require('fs');
|
Object.assign(
|
||||||
const path = require('path');
|
{
|
||||||
const waitForLibLoad = callback => {
|
header,
|
||||||
if (!global.BDEvents) return callback();
|
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
const onLoaded = e => {
|
red: false,
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
confirmText: 'Download Now',
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
cancelText: 'Cancel',
|
||||||
callback();
|
onConfirm: () => {
|
||||||
};
|
onHeckWouldYouLookAtThat();
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
const request = require('request');
|
||||||
};
|
const fs = require('fs');
|
||||||
const onDone = () => {
|
const path = require('path');
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents) return callback();
|
||||||
else {
|
const onLoaded = e => {
|
||||||
const listener = () => {
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
pluginModule.reloadPlugin(this.name);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
}
|
};
|
||||||
};
|
const onDone = () => {
|
||||||
const downloadXenoLib = () => {
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (global.XenoLib) return onDone();
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
else {
|
||||||
if (error) return onFail();
|
const listener = () => {
|
||||||
onDone();
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
pluginModule.reloadPlugin(this.name);
|
||||||
});
|
};
|
||||||
};
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
if (!global.ZeresPluginLibrary) {
|
}
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
};
|
||||||
if (error) return onFail();
|
const downloadXenoLib = () => {
|
||||||
waitForLibLoad(downloadXenoLib);
|
if (global.XenoLib) return onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
});
|
if (error) return onFail();
|
||||||
} else downloadXenoLib();
|
onDone();
|
||||||
}
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
},
|
});
|
||||||
props
|
};
|
||||||
|
if (!global.ZeresPluginLibrary) {
|
||||||
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
|
if (error) return onFail();
|
||||||
|
waitForLibLoad(downloadXenoLib);
|
||||||
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
|
});
|
||||||
|
} else downloadXenoLib();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -345,58 +345,106 @@ var CrashRecovery = (() => {
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
class TempErrorBoundary extends BdApi.React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
componentDidCatch(err, inf) {
|
||||||
|
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`);
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
if (typeof this.props.onError === 'function') this.props.onError(err);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let modalId;
|
||||||
|
const onHeckWouldYouLookAtThat = (() => {
|
||||||
|
if (!global.pluginModule || !global.BDEvents) return;
|
||||||
|
if (XenoLibMissing) {
|
||||||
|
const listener = () => {
|
||||||
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
|
return () => BDEvents.off('xenolib-loaded', listener);
|
||||||
|
} else {
|
||||||
|
const onLoaded = e => {
|
||||||
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
|
return () => BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
modalId = ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
TempErrorBoundary,
|
||||||
Object.assign(
|
{
|
||||||
{
|
label: 'missing dependency modal',
|
||||||
header,
|
onError: () => {
|
||||||
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
ModalStack.popWithKey(modalId); /* smh... */
|
||||||
red: false,
|
onFail();
|
||||||
confirmText: 'Download Now',
|
}
|
||||||
cancelText: 'Cancel',
|
},
|
||||||
onConfirm: () => {
|
BdApi.React.createElement(
|
||||||
const request = require('request');
|
ConfirmationModal,
|
||||||
const fs = require('fs');
|
Object.assign(
|
||||||
const path = require('path');
|
{
|
||||||
const waitForLibLoad = callback => {
|
header,
|
||||||
if (!global.BDEvents) return callback();
|
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
const onLoaded = e => {
|
red: false,
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
confirmText: 'Download Now',
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
cancelText: 'Cancel',
|
||||||
callback();
|
onConfirm: () => {
|
||||||
};
|
onHeckWouldYouLookAtThat();
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
const request = require('request');
|
||||||
};
|
const fs = require('fs');
|
||||||
const onDone = () => {
|
const path = require('path');
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents) return callback();
|
||||||
else {
|
const onLoaded = e => {
|
||||||
const listener = () => {
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
pluginModule.reloadPlugin(this.name);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
}
|
};
|
||||||
};
|
const onDone = () => {
|
||||||
const downloadXenoLib = () => {
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (global.XenoLib) return onDone();
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
else {
|
||||||
if (error) return onFail();
|
const listener = () => {
|
||||||
onDone();
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
pluginModule.reloadPlugin(this.name);
|
||||||
});
|
};
|
||||||
};
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
if (!global.ZeresPluginLibrary) {
|
}
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
};
|
||||||
if (error) return onFail();
|
const downloadXenoLib = () => {
|
||||||
waitForLibLoad(downloadXenoLib);
|
if (global.XenoLib) return onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
});
|
if (error) return onFail();
|
||||||
} else downloadXenoLib();
|
onDone();
|
||||||
}
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
},
|
});
|
||||||
props
|
};
|
||||||
|
if (!global.ZeresPluginLibrary) {
|
||||||
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
|
if (error) return onFail();
|
||||||
|
waitForLibLoad(downloadXenoLib);
|
||||||
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
|
});
|
||||||
|
} else downloadXenoLib();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -1169,58 +1169,106 @@ var MentionAliasesRedux = (() => {
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
class TempErrorBoundary extends BdApi.React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
componentDidCatch(err, inf) {
|
||||||
|
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`);
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
if (typeof this.props.onError === 'function') this.props.onError(err);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let modalId;
|
||||||
|
const onHeckWouldYouLookAtThat = (() => {
|
||||||
|
if (!global.pluginModule || !global.BDEvents) return;
|
||||||
|
if (XenoLibMissing) {
|
||||||
|
const listener = () => {
|
||||||
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
|
return () => BDEvents.off('xenolib-loaded', listener);
|
||||||
|
} else {
|
||||||
|
const onLoaded = e => {
|
||||||
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
|
return () => BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
modalId = ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
TempErrorBoundary,
|
||||||
Object.assign(
|
{
|
||||||
{
|
label: 'missing dependency modal',
|
||||||
header,
|
onError: () => {
|
||||||
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
ModalStack.popWithKey(modalId); /* smh... */
|
||||||
red: false,
|
onFail();
|
||||||
confirmText: 'Download Now',
|
}
|
||||||
cancelText: 'Cancel',
|
},
|
||||||
onConfirm: () => {
|
BdApi.React.createElement(
|
||||||
const request = require('request');
|
ConfirmationModal,
|
||||||
const fs = require('fs');
|
Object.assign(
|
||||||
const path = require('path');
|
{
|
||||||
const waitForLibLoad = callback => {
|
header,
|
||||||
if (!global.BDEvents) return callback();
|
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
const onLoaded = e => {
|
red: false,
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
confirmText: 'Download Now',
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
cancelText: 'Cancel',
|
||||||
callback();
|
onConfirm: () => {
|
||||||
};
|
onHeckWouldYouLookAtThat();
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
const request = require('request');
|
||||||
};
|
const fs = require('fs');
|
||||||
const onDone = () => {
|
const path = require('path');
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents) return callback();
|
||||||
else {
|
const onLoaded = e => {
|
||||||
const listener = () => {
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
pluginModule.reloadPlugin(this.name);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
}
|
};
|
||||||
};
|
const onDone = () => {
|
||||||
const downloadXenoLib = () => {
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (global.XenoLib) return onDone();
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
else {
|
||||||
if (error) return onFail();
|
const listener = () => {
|
||||||
onDone();
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
pluginModule.reloadPlugin(this.name);
|
||||||
});
|
};
|
||||||
};
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
if (!global.ZeresPluginLibrary) {
|
}
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
};
|
||||||
if (error) return onFail();
|
const downloadXenoLib = () => {
|
||||||
waitForLibLoad(downloadXenoLib);
|
if (global.XenoLib) return onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
});
|
if (error) return onFail();
|
||||||
} else downloadXenoLib();
|
onDone();
|
||||||
}
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
},
|
});
|
||||||
props
|
};
|
||||||
|
if (!global.ZeresPluginLibrary) {
|
||||||
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
|
if (error) return onFail();
|
||||||
|
waitForLibLoad(downloadXenoLib);
|
||||||
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
|
});
|
||||||
|
} else downloadXenoLib();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -914,68 +914,116 @@ var SaveToRedux = (() => {
|
||||||
}
|
}
|
||||||
stop() {}
|
stop() {}
|
||||||
load() {
|
load() {
|
||||||
const ezlibMissing = !global.XenoLib;
|
const XenoLibMissing = !global.XenoLib;
|
||||||
const zlibMissing = !global.ZeresPluginLibrary;
|
const zlibMissing = !global.ZeresPluginLibrary;
|
||||||
const bothLibsMissing = ezlibMissing && zlibMissing;
|
const bothLibsMissing = XenoLibMissing && zlibMissing;
|
||||||
const header = `Missing ${(bothLibsMissing && 'Libraries') || 'Library'}`;
|
const header = `Missing ${(bothLibsMissing && 'Libraries') || 'Library'}`;
|
||||||
const content = `The ${(bothLibsMissing && 'Libraries') || 'Library'} ${(zlibMissing && 'ZeresPluginLibrary') || ''} ${(ezlibMissing && (zlibMissing ? 'and XenoLib' : 'XenoLib')) || ''} required for ${this.name} ${(bothLibsMissing && 'are') || 'is'} missing.`;
|
const content = `The ${(bothLibsMissing && 'Libraries') || 'Library'} ${(zlibMissing && 'ZeresPluginLibrary') || ''} ${(XenoLibMissing && (zlibMissing ? 'and XenoLib' : 'XenoLib')) || ''} required for ${this.name} ${(bothLibsMissing && 'are') || 'is'} missing.`;
|
||||||
const ModalStack = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey');
|
const ModalStack = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey');
|
||||||
const TextElement = BdApi.findModuleByProps('Sizes', 'Weights');
|
const TextElement = BdApi.findModuleByProps('Sizes', 'Weights');
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
class TempErrorBoundary extends BdApi.React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
componentDidCatch(err, inf) {
|
||||||
|
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`);
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
if (typeof this.props.onError === 'function') this.props.onError(err);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let modalId;
|
||||||
|
const onHeckWouldYouLookAtThat = (() => {
|
||||||
|
if (!global.pluginModule || !global.BDEvents) return;
|
||||||
|
if (XenoLibMissing) {
|
||||||
|
const listener = () => {
|
||||||
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
|
return () => BDEvents.off('xenolib-loaded', listener);
|
||||||
|
} else {
|
||||||
|
const onLoaded = e => {
|
||||||
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
|
return () => BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
modalId = ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
TempErrorBoundary,
|
||||||
Object.assign(
|
{
|
||||||
{
|
label: 'missing dependency modal',
|
||||||
header,
|
onError: () => {
|
||||||
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
ModalStack.popWithKey(modalId); /* smh... */
|
||||||
red: false,
|
onFail();
|
||||||
confirmText: 'Download Now',
|
}
|
||||||
cancelText: 'Cancel',
|
},
|
||||||
onConfirm: () => {
|
BdApi.React.createElement(
|
||||||
const request = require('request');
|
ConfirmationModal,
|
||||||
const fs = require('fs');
|
Object.assign(
|
||||||
const path = require('path');
|
{
|
||||||
const waitForLibLoad = callback => {
|
header,
|
||||||
if (!global.BDEvents) return callback();
|
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
const onLoaded = e => {
|
red: false,
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
confirmText: 'Download Now',
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
cancelText: 'Cancel',
|
||||||
callback();
|
onConfirm: () => {
|
||||||
};
|
onHeckWouldYouLookAtThat();
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
const request = require('request');
|
||||||
};
|
const fs = require('fs');
|
||||||
const onDone = () => {
|
const path = require('path');
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents) return callback();
|
||||||
else {
|
const onLoaded = e => {
|
||||||
const listener = () => {
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
pluginModule.reloadPlugin(this.name);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
}
|
};
|
||||||
};
|
const onDone = () => {
|
||||||
const downloadXenoLib = () => {
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (global.XenoLib) return onDone();
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
else {
|
||||||
if (error) return onFail();
|
const listener = () => {
|
||||||
onDone();
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
pluginModule.reloadPlugin(this.name);
|
||||||
});
|
};
|
||||||
};
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
if (!global.ZeresPluginLibrary) {
|
}
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
};
|
||||||
if (error) return onFail();
|
const downloadXenoLib = () => {
|
||||||
waitForLibLoad(downloadXenoLib);
|
if (global.XenoLib) return onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
});
|
if (error) return onFail();
|
||||||
} else downloadXenoLib();
|
onDone();
|
||||||
}
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
},
|
});
|
||||||
props
|
};
|
||||||
|
if (!global.ZeresPluginLibrary) {
|
||||||
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
|
if (error) return onFail();
|
||||||
|
waitForLibLoad(downloadXenoLib);
|
||||||
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
|
});
|
||||||
|
} else downloadXenoLib();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -555,58 +555,106 @@ var UnreadBadgesRedux = (() => {
|
||||||
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
const ConfirmationModal = BdApi.findModule(m => m.defaultProps && m.key && m.key() === 'confirm-modal');
|
||||||
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
const onFail = () => BdApi.getCore().alert(header, `${content}<br/>Due to a slight mishap however, you'll have to download the libraries yourself. After opening the links, do CTRL + S to download the library.<br/>${(zlibMissing && '<br/><a href="https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>') || ''}${(zlibMissing && '<br/><a href="http://localhost:7474/XenoLib.js"target="_blank">Click here to download XenoLib</a>') || ''}`);
|
||||||
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
if (!ModalStack || !ConfirmationModal || !TextElement) return onFail();
|
||||||
ModalStack.push(props => {
|
class TempErrorBoundary extends BdApi.React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
componentDidCatch(err, inf) {
|
||||||
|
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`);
|
||||||
|
this.setState({ hasError: true });
|
||||||
|
if (typeof this.props.onError === 'function') this.props.onError(err);
|
||||||
|
}
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) return null;
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let modalId;
|
||||||
|
const onHeckWouldYouLookAtThat = (() => {
|
||||||
|
if (!global.pluginModule || !global.BDEvents) return;
|
||||||
|
if (XenoLibMissing) {
|
||||||
|
const listener = () => {
|
||||||
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
|
return () => BDEvents.off('xenolib-loaded', listener);
|
||||||
|
} else {
|
||||||
|
const onLoaded = e => {
|
||||||
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
ModalStack.popWithKey(modalId); /* make it easier on the user */
|
||||||
|
pluginModule.reloadPlugin(this.name);
|
||||||
|
};
|
||||||
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
|
return () => BDEvents.off('plugin-loaded', onLoaded);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
modalId = ModalStack.push(props => {
|
||||||
return BdApi.React.createElement(
|
return BdApi.React.createElement(
|
||||||
ConfirmationModal,
|
TempErrorBoundary,
|
||||||
Object.assign(
|
{
|
||||||
{
|
label: 'missing dependency modal',
|
||||||
header,
|
onError: () => {
|
||||||
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
ModalStack.popWithKey(modalId); /* smh... */
|
||||||
red: false,
|
onFail();
|
||||||
confirmText: 'Download Now',
|
}
|
||||||
cancelText: 'Cancel',
|
},
|
||||||
onConfirm: () => {
|
BdApi.React.createElement(
|
||||||
const request = require('request');
|
ConfirmationModal,
|
||||||
const fs = require('fs');
|
Object.assign(
|
||||||
const path = require('path');
|
{
|
||||||
const waitForLibLoad = callback => {
|
header,
|
||||||
if (!global.BDEvents) return callback();
|
children: [BdApi.React.createElement(TextElement, { color: TextElement.Colors.PRIMARY, children: [`${content} Please click Download Now to install ${(bothLibsMissing && 'them') || 'it'}.`] })],
|
||||||
const onLoaded = e => {
|
red: false,
|
||||||
if (e !== 'ZeresPluginLibrary') return;
|
confirmText: 'Download Now',
|
||||||
BDEvents.off('plugin-loaded', onLoaded);
|
cancelText: 'Cancel',
|
||||||
callback();
|
onConfirm: () => {
|
||||||
};
|
onHeckWouldYouLookAtThat();
|
||||||
BDEvents.on('plugin-loaded', onLoaded);
|
const request = require('request');
|
||||||
};
|
const fs = require('fs');
|
||||||
const onDone = () => {
|
const path = require('path');
|
||||||
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
const waitForLibLoad = callback => {
|
||||||
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
if (!global.BDEvents) return callback();
|
||||||
else {
|
const onLoaded = e => {
|
||||||
const listener = () => {
|
if (e !== 'ZeresPluginLibrary') return;
|
||||||
pluginModule.reloadPlugin(this.name);
|
BDEvents.off('plugin-loaded', onLoaded);
|
||||||
BDEvents.off('xenolib-loaded', listener);
|
callback();
|
||||||
};
|
};
|
||||||
BDEvents.on('xenolib-loaded', listener);
|
BDEvents.on('plugin-loaded', onLoaded);
|
||||||
}
|
};
|
||||||
};
|
const onDone = () => {
|
||||||
const downloadXenoLib = () => {
|
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return;
|
||||||
if (global.XenoLib) return onDone();
|
if (!global.BDEvents || global.XenoLib) pluginModule.reloadPlugin(this.name);
|
||||||
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
else {
|
||||||
if (error) return onFail();
|
const listener = () => {
|
||||||
onDone();
|
BDEvents.off('xenolib-loaded', listener);
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
pluginModule.reloadPlugin(this.name);
|
||||||
});
|
};
|
||||||
};
|
BDEvents.on('xenolib-loaded', listener);
|
||||||
if (!global.ZeresPluginLibrary) {
|
}
|
||||||
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
};
|
||||||
if (error) return onFail();
|
const downloadXenoLib = () => {
|
||||||
waitForLibLoad(downloadXenoLib);
|
if (global.XenoLib) return onDone();
|
||||||
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
request('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (error, response, body) => {
|
||||||
});
|
if (error) return onFail();
|
||||||
} else downloadXenoLib();
|
onDone();
|
||||||
}
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), body, () => {});
|
||||||
},
|
});
|
||||||
props
|
};
|
||||||
|
if (!global.ZeresPluginLibrary) {
|
||||||
|
request('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (error, response, body) => {
|
||||||
|
if (error) return onFail();
|
||||||
|
waitForLibLoad(downloadXenoLib);
|
||||||
|
fs.writeFile(path.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), body, () => {});
|
||||||
|
});
|
||||||
|
} else downloadXenoLib();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
props
|
||||||
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue