fix fuck up in IAN

This commit is contained in:
_Lighty_ 2020-03-15 12:50:57 +01:00
parent 4f5b8b01cd
commit 0cb4c7dee5
1 changed files with 66 additions and 76 deletions

View File

@ -102,8 +102,8 @@ var InAppNotifications = (() => {
oMESSAGE_CREATE(e); oMESSAGE_CREATE(e);
} catch (e) { } catch (e) {
this.errorCount++; this.errorCount++;
Logger.stacktrace('Error in MESSAGE_CREATE dispatch handler', e);
if (this.errorCount >= 10) { if (this.errorCount >= 10) {
Logger.stacktrace('Error in MESSAGE_CREATE dispatch handler', e);
PluginUpdater.checkForUpdate(this.name, this.version, this._config.info.github_raw); PluginUpdater.checkForUpdate(this.name, this.version, this._config.info.github_raw);
XenoLib.Notifications.error(`[**${this.name}**] Plugin is throwing errors and is in a broken state, please update it or ${GuildStore.getGuild(XenoLib.supportServerId) ? 'go to <#639665366380838924>' : '[join my support server](https://discord.gg/NYvWdN5)'} for further assistance.`, { timeout: 0 }); XenoLib.Notifications.error(`[**${this.name}**] Plugin is throwing errors and is in a broken state, please update it or ${GuildStore.getGuild(XenoLib.supportServerId) ? 'go to <#639665366380838924>' : '[join my support server](https://discord.gg/NYvWdN5)'} for further assistance.`, { timeout: 0 });
try { try {
@ -112,6 +112,9 @@ var InAppNotifications = (() => {
} }
} }
}; };
try {
ModalStack.popWithKey(`${this.name}_DEP_MODAL`);
} catch (e) {}
} }
onStart() { onStart() {
this.errorCount = 0; this.errorCount = 0;
@ -352,7 +355,7 @@ var InAppNotifications = (() => {
n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e), n = (n, e) => n && n._config && n._config.info && n._config.info.version && i(n._config.info.version, e),
e = BdApi.getPlugin('ZeresPluginLibrary'), e = BdApi.getPlugin('ZeresPluginLibrary'),
author = BdApi.getPlugin('XenoLib'); author = BdApi.getPlugin('XenoLib');
n(e, '1.2.10') && (ZeresPluginLibraryOutdated = !0), n(author, '1.3.11') && (XenoLibOutdated = !0); n(e, '1.2.11') && (ZeresPluginLibraryOutdated = !0), n(author, '1.3.14') && (XenoLibOutdated = !0);
} }
} catch (i) { } catch (i) {
console.error('Error checking if libraries are out of date', i); console.error('Error checking if libraries are out of date', i);
@ -360,6 +363,9 @@ var InAppNotifications = (() => {
return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated return !global.ZeresPluginLibrary || !global.XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated
? class { ? class {
constructor() {
this._XL_PLUGIN = true;
}
getName() { getName() {
return this.name.replace(/\s+/g, ''); return this.name.replace(/\s+/g, '');
} }
@ -374,96 +380,80 @@ var InAppNotifications = (() => {
} }
stop() {} stop() {}
load() { load() {
const a = !global.XenoLib, const a = BdApi.findModuleByProps('isModalOpen');
b = !global.ZeresPluginLibrary, if (a && a.isModalOpen(`${this.name}_DEP_MODAL`)) return;
c = (a && b) || ((a || b) && (XenoLibOutdated || ZeresPluginLibraryOutdated)) || XenoLibOutdated || ZeresPluginLibraryOutdated, const b = !global.XenoLib,
d = (() => { c = !global.ZeresPluginLibrary,
let d = ''; d = (b && c) || ((b || c) && (XenoLibOutdated || ZeresPluginLibraryOutdated)),
return a || b ? (d += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (d += `Outdated `), (d += `${c ? 'Libraries' : 'Library'} `), d;
})(),
e = (() => { e = (() => {
let d = `The ${c ? 'libraries' : 'library'} `; let a = '';
return a || XenoLibOutdated ? ((d += 'XenoLib '), (b || ZeresPluginLibraryOutdated) && (d += 'and ZeresPluginLibrary ')) : (b || ZeresPluginLibraryOutdated) && (d += 'ZeresPluginLibrary '), (d += `required for ${this.name} ${c ? 'are' : 'is'} ${a || b ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (a || b ? ' and/or outdated' : 'outdated') : ''}.`), d; return b || c ? (a += `Missing${XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : ''} `) : (XenoLibOutdated || ZeresPluginLibraryOutdated) && (a += `Outdated `), (a += `${d ? 'Libraries' : 'Library'} `), a;
})(), })(),
f = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'), f = (() => {
g = BdApi.findModuleByProps('Sizes', 'Weights'), let a = `The ${d ? 'libraries' : 'library'} `;
h = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()), return b || XenoLibOutdated ? ((a += 'XenoLib '), (c || ZeresPluginLibraryOutdated) && (a += 'and ZeresPluginLibrary ')) : (c || ZeresPluginLibraryOutdated) && (a += 'ZeresPluginLibrary '), (a += `required for ${this.name} ${d ? 'are' : 'is'} ${b || c ? 'missing' : ''}${XenoLibOutdated || ZeresPluginLibraryOutdated ? (b || c ? ' and/or outdated' : 'outdated') : ''}.`), a;
i = () => BdApi.getCore().alert(d, `${e}<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/>${b || ZeresPluginLibraryOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/rauenzi/BDPluginLibrary/blob/master/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>' : ''}${a || XenoLibOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/1XenoLib.plugin.js"target="_blank">Click here to download XenoLib</a>' : ''}`); })(),
if (!f || !h || !g) return i(); g = BdApi.findModuleByProps('push', 'update', 'pop', 'popWithKey'),
let j; h = BdApi.findModuleByProps('Sizes', 'Weights'),
const k = (() => { i = BdApi.findModule(a => a.defaultProps && a.key && 'confirm-modal' === a.key()),
if (!global.pluginModule || !global.BDEvents) return; j = () => BdApi.getCore().alert(e, `${f}<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/>${c || ZeresPluginLibraryOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/rauenzi/BDPluginLibrary/blob/master/release/0PluginLibrary.plugin.js"target="_blank">Click here to download ZeresPluginLibrary</a>' : ''}${b || XenoLibOutdated ? '<br/><a href="http://betterdiscord.net/ghdl/?url=https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/1XenoLib.plugin.js"target="_blank">Click here to download XenoLib</a>' : ''}`);
if (a || XenoLibOutdated) { if (!g || !i || !h) return j();
const a = () => { class k extends BdApi.React.PureComponent {
BDEvents.off('xenolib-loaded', a), f.popWithKey(j), pluginModule.reloadPlugin(this.name);
};
return BDEvents.on('xenolib-loaded', a), () => BDEvents.off('xenolib-loaded', a);
}
const b = a => {
'ZeresPluginLibrary' !== a || (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b), f.popWithKey(j), pluginModule.reloadPlugin(this.name));
};
return BDEvents.on('plugin-loaded', b), BDEvents.on('plugin-reloaded', b), () => (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b));
})();
class l extends BdApi.React.PureComponent {
constructor(a) { constructor(a) {
super(a), (this.state = { hasError: !1 }); super(a), (this.state = { hasError: !1 });
} }
componentDidCatch(a, b) { componentDidCatch(a) {
console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`), this.setState({ hasError: !0 }), 'function' == typeof this.props.onError && this.props.onError(a); console.error(`Error in ${this.props.label}, screenshot or copy paste the error above to Lighty for help.`), this.setState({ hasError: !0 }), 'function' == typeof this.props.onError && this.props.onError(a);
} }
render() { render() {
return this.state.hasError ? null : this.props.children; return this.state.hasError ? null : this.props.children;
} }
} }
j = f.push(a => class l extends i {
BdApi.React.createElement( submitModal() {
l, this.props.onConfirm();
{ }
label: 'missing dependency modal', }
onError: () => { let m = !1;
f.popWithKey(j), i(); const n = g.push(
} a =>
},
BdApi.React.createElement( BdApi.React.createElement(
h, k,
Object.assign( {
{ label: 'missing dependency modal',
header: d, onError: () => {
children: [BdApi.React.createElement(g, { color: g.Colors.PRIMARY, children: [`${e} Please click Download Now to download ${c ? 'them' : 'it'}.`] })], g.popWithKey(n), j();
red: !1, }
confirmText: 'Download Now', },
cancelText: 'Cancel', BdApi.React.createElement(
onConfirm: () => { l,
k(); Object.assign(
const a = require('request'), {
b = require('fs'), header: e,
c = require('path'), children: [BdApi.React.createElement(h, { color: h.Colors.PRIMARY, children: [`${f} Please click Download Now to download ${d ? 'them' : 'it'}.`] })],
d = a => { red: !1,
if (!global.BDEvents) return a(); confirmText: 'Download Now',
const b = c => { cancelText: 'Cancel',
'ZeresPluginLibrary' !== c || (BDEvents.off('plugin-loaded', b), BDEvents.off('plugin-reloaded', b), a()); onConfirm: () => {
if (m) return;
m = !0;
const a = require('request'),
b = require('fs'),
c = require('path'),
d = () => {
(global.XenoLib && !XenoLibOutdated) || a('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (a, d, e) => (a ? j() : void b.writeFile(c.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), e, () => {})));
}; };
BDEvents.on('plugin-loaded', b), BDEvents.on('plugin-reloaded', b); !global.ZeresPluginLibrary || ZeresPluginLibraryOutdated ? a('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (a, e, f) => (a ? j() : void (b.writeFile(c.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), f, () => {}), d()))) : d();
}, }
e = () => { },
if (!global.pluginModule || (!global.BDEvents && !global.XenoLib)) return; a
if ((global.XenoLib && !XenoLibOutdated) || !global.BDEvents) return pluginModule.reloadPlugin(this.name); )
const a = () => {
BDEvents.off('xenolib-loaded', a), pluginModule.reloadPlugin(this.name);
};
BDEvents.on('xenolib-loaded', a);
},
f = () => (global.XenoLib && !XenoLibOutdated ? e() : void a('https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js', (a, d, f) => (a ? i() : void (e(), b.writeFile(c.join(window.ContentManager.pluginsFolder, '1XenoLib.plugin.js'), f, () => {})))));
!global.ZeresPluginLibrary || ZeresPluginLibraryOutdated ? a('https://rauenzi.github.io/BDPluginLibrary/release/0PluginLibrary.plugin.js', (a, e, g) => (a ? i() : void (d(f), b.writeFile(c.join(window.ContentManager.pluginsFolder, '0PluginLibrary.plugin.js'), g, () => {})))) : f();
}
},
a
) )
) ),
) void 0,
`${this.name}_DEP_MODAL`
); );
} }
start() {} start() {}
get [Symbol.toStringTag]() { get [Symbol.toStringTag]() {
return 'Plugin'; return 'Plugin';