2020-03-12 16:23:56 +01:00
//META{"name":"CrashRecovery","source":"https://github.com/1Lighty/BetterDiscordPlugins/blob/master/Plugins/CrashRecovery/","website":"https://1lighty.github.io/BetterDiscordStuff/?plugin=CrashRecovery","authorId":"239513071272329217","invite":"NYvWdN5","donate":"https://paypal.me/lighty13"}*//
2020-01-08 00:17:36 +01:00
/ * @ c c _ o n
@ if ( @ _jscript )
// Offer to self-install for clueless users that try to run this directly.
var shell = WScript . CreateObject ( 'WScript.Shell' ) ;
var fs = new ActiveXObject ( 'Scripting.FileSystemObject' ) ;
var pathPlugins = shell . ExpandEnvironmentStrings ( '%APPDATA%\\BetterDiscord\\plugins' ) ;
var pathSelf = WScript . ScriptFullName ;
// Put the user at ease by addressing them in the first person
shell . Popup ( 'It looks like you\'ve mistakenly tried to run me directly. \n(Don\'t do that!)' , 0 , 'I\'m a plugin for BetterDiscord' , 0x30 ) ;
if ( fs . GetParentFolderName ( pathSelf ) === fs . GetAbsolutePathName ( pathPlugins ) ) {
2020-03-31 21:31:22 +02:00
shell . Popup ( 'I\'m in the correct folder already.\nJust go to settings, plugins and enable me.' , 0 , 'I\'m already installed' , 0x40 ) ;
2020-01-08 00:17:36 +01:00
} else if ( ! fs . FolderExists ( pathPlugins ) ) {
shell . Popup ( 'I can\'t find the BetterDiscord plugins folder.\nAre you sure it\'s even installed?' , 0 , 'Can\'t install myself' , 0x10 ) ;
} else if ( shell . Popup ( 'Should I copy myself to BetterDiscord\'s plugins folder for you?' , 0 , 'Do you need some help?' , 0x34 ) === 6 ) {
fs . CopyFile ( pathSelf , fs . BuildPath ( pathPlugins , fs . GetFileName ( pathSelf ) ) , true ) ;
// Show the user where to put plugins in the future
shell . Exec ( 'explorer ' + pathPlugins ) ;
2020-03-31 21:31:22 +02:00
shell . Popup ( 'I\'m installed!\nJust go to settings, plugins and enable me!' , 0 , 'Successfully installed' , 0x40 ) ;
2020-01-08 00:17:36 +01:00
}
WScript . Quit ( ) ;
@ else @ * /
/ *
* Copyright © 2019 - 2020 , _Lighty _
* All rights reserved .
* Code may not be redistributed , modified or otherwise taken without explicit permission .
* /
var CrashRecovery = ( ( ) => {
/* Setup */
const config = {
main : 'index.js' ,
info : {
name : 'CrashRecovery' ,
authors : [
{
name : 'Lighty' ,
discord _id : '239513071272329217' ,
github _username : '1Lighty' ,
twitter _username : ''
}
] ,
2020-03-31 21:31:22 +02:00
version : '0.1.5' ,
2020-03-05 16:16:55 +01:00
description : 'In the event that your Discord crashes, the plugin enables you to get Discord back to a working state, without needing to reload at all.' ,
2020-01-08 00:17:36 +01:00
github : 'https://github.com/1Lighty' ,
github _raw : 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/CrashRecovery/CrashRecovery.plugin.js'
} ,
changelog : [
{
2020-03-05 16:16:55 +01:00
title : 'misc changes' ,
2020-01-10 11:09:26 +01:00
type : 'fixed' ,
2020-03-31 21:31:22 +02:00
items : [ 'Fixed startup error in console' ]
2020-03-05 16:16:55 +01:00
}
] ,
defaultConfig : [
{
name : 'Enable step 3' ,
note : 'Moves channel switch to a third and last step, otherwise it switches on step 2' ,
id : 'useThirdStep' ,
type : 'switch' ,
value : true
2020-01-08 00:17:36 +01:00
}
]
} ;
/* Build */
const buildPlugin = ( [ Plugin , Api ] ) => {
2020-03-05 16:16:55 +01:00
const { Logger , Utilities , WebpackModules , DiscordModules , Patcher , PluginUtilities , ReactTools , PluginUpdater } = Api ;
const { React , Dispatcher , FlexChild : Flex , GuildStore } = DiscordModules ;
2020-01-08 00:17:36 +01:00
2020-03-05 16:16:55 +01:00
const DelayedCall = ( WebpackModules . getByProps ( 'DelayedCall' ) || { } ) . DelayedCall ;
2020-01-08 00:17:36 +01:00
const ElectronDiscordModule = WebpackModules . getByProps ( 'cleanupDisplaySleep' ) ;
return class CrashRecovery extends Plugin {
constructor ( ) {
super ( ) ;
XenoLib . changeName ( _ _filename , 'CrashRecovery' ) ;
2020-03-05 16:16:55 +01:00
this . _startFailure = message => {
PluginUpdater . checkForUpdate ( this . name , this . version , this . _config . info . github _raw ) ;
XenoLib . Notifications . error ( ` [** ${ this . name } **] ${ message } Please update it, press CTRL + R, or ${ GuildStore . getGuild ( XenoLib . supportServerId ) ? 'go to <#639665366380838924>' : '[join my support server](https://discord.gg/NYvWdN5)' } for further assistance. ` , { timeout : 0 } ) ;
} ;
const oOnStart = this . onStart . bind ( this ) ;
this . onStart = ( ) => {
try {
oOnStart ( ) ;
} catch ( e ) {
Logger . stacktrace ( 'Failed to start!' , e ) ;
this . _startFailure ( 'Failed to start!' ) ;
try {
this . onStop ( ) ;
} catch ( e ) { }
}
} ;
2020-03-12 16:23:56 +01:00
try {
ModalStack . popWithKey ( ` ${ this . name } _DEP_MODAL ` ) ;
} catch ( e ) { }
2020-01-08 00:17:36 +01:00
}
onStart ( ) {
2020-03-05 16:16:55 +01:00
this . attempts = 0 ;
this . promises = { state : { cancelled : false } } ;
if ( ! DelayedCall ) return this . _startFailure ( 'DelayedCall missing, plugin cannot function.' ) ;
2020-01-08 00:17:36 +01:00
delete this . onCrashRecoveredDelayedCall ;
this . onCrashRecoveredDelayedCall = new DelayedCall ( 1000 , ( ) => {
XenoLib . Notifications . remove ( this . notificationId ) ;
this . notificationId = null ;
if ( this . disabledPlugins ) XenoLib . Notifications . danger ( ` ${ this . disabledPlugins . map ( e => e ) } ${ this . disabledPlugins . length > 1 ? 'have' : 'has' } been disabled to recover from the crash ` , { timeout : 0 } ) ;
if ( this . suspectedPlugin ) XenoLib . Notifications . danger ( ` ${ this . suspectedPlugin } ${ this . suspectedPlugin2 !== this . suspectedPlugin && this . suspectedPlugin2 ? 'or ' + this . suspectedPlugin2 : '' } is suspected of causing the crash. ` , { timeout : 10000 } ) ;
if ( this . autoDisabledPlugins && this . autoDisabledPlugins . length ) {
setTimeout ( ( ) => {
XenoLib . Notifications . danger ( ` ${ this . autoDisabledPlugins . length } ${ this . autoDisabledPlugins . length > 1 ? 'plugins have' : 'plugin has' } been reenabled due to the crash disabling ${ this . autoDisabledPlugins . length > 1 ? 'them' : 'it' } ` , { timeout : 10000 } ) ;
this . autoDisabledPlugins . forEach ( ( { name } ) => {
2020-03-31 21:31:22 +02:00
try {
pluginModule . stopPlugin ( name ) ;
pluginCookie [ name ] = true ;
pluginModule . startPlugin ( name ) ;
} catch ( err ) {
try {
pluginCookie [ name ] = false ;
pluginModule . stopPlugin ( name ) ;
} catch ( err ) {
/* bruh idk */
}
}
2020-01-08 00:17:36 +01:00
} ) ;
pluginModule . savePluginData ( ) ;
this . autoDisabledPlugins = [ ] ;
} , 1000 ) ;
}
this . disabledPlugins = null ;
this . suspectedPlugin = null ;
this . suspectedPlugin2 = null ;
this . attempts = 0 ;
2020-03-05 16:16:55 +01:00
const appMount = document . querySelector ( '#app-mount' ) ;
appMount . append ( document . querySelector ( '.xenoLib-notifications' ) ) ;
const BIVOverlay = document . querySelector ( '.biv-overlay' ) ;
if ( BIVOverlay ) appMount . append ( BIVOverlay ) ;
Logger . info ( 'Corrected incorrectly placed containers' ) ;
2020-01-08 00:17:36 +01:00
} ) ;
this . patchAll ( ) ;
2020-03-05 16:16:55 +01:00
if ( ! document . querySelector ( ` . ${ XenoLib . getSingleClass ( 'errorPage' ) } ` ) )
this . _ _safeClearTimeout = setTimeout ( ( ) => {
if ( global . bdpluginErrors && global . bdpluginErrors . length ) {
2020-03-31 21:31:22 +02:00
global . bdpluginErrors . splice ( 0 , global . bdpluginErrors . length ) ;
2020-03-05 16:16:55 +01:00
Logger . info ( 'Cleared global.bdpluginErrors' ) ;
}
} , 7500 ) ;
2020-01-08 00:17:36 +01:00
}
onStop ( ) {
this . promises . state . cancelled = true ;
Patcher . unpatchAll ( ) ;
if ( this . notificationId ) XenoLib . Notifications . remove ( this . notificationId ) ;
}
queryResponsiblePlugins ( stack ) {
try {
2020-03-05 16:16:55 +01:00
const match = stack . match ( /^.*(?:\\|\/|VM\d+ )([^\/\\\n]+)\.plugin\.js/gm ) ;
2020-01-08 00:17:36 +01:00
const plugins = [ ] ;
if ( ! match || ! match . length ) return null ;
2020-03-05 16:16:55 +01:00
let onDispatchEventFound = false ;
2020-01-08 00:17:36 +01:00
for ( let i = 0 ; i < match . length ; i ++ ) {
2020-03-05 16:16:55 +01:00
const pluginName = match [ i ] . match ( /(?:\\|\/)([^\/\\]+)\.plugin\.js/ ) [ 1 ] ;
if ( match [ i ] . indexOf ( 'MessageLoggerV2.onDispatchEvent' ) !== - 1 ) {
onDispatchEventFound = true ;
continue ;
}
if ( onDispatchEventFound && /Object\.callback.*(?:\\|\/|VM\d+ )MessageLoggerV2\.plugin\.js/ . test ( match [ i ] ) ) continue ;
2020-01-08 00:17:36 +01:00
if ( pluginName === '0PluginLibrary' || pluginName === this . name ) continue ;
const bbdplugin = Object . values ( bdplugins ) . find ( m => m . filename . startsWith ( pluginName ) ) ;
const name = ( bbdplugin && bbdplugin . name ) || pluginName ;
if ( this . disabledPlugins && this . disabledPlugins . indexOf ( name ) !== - 1 ) return { name : name } ;
plugins . push ( name ) ;
}
return plugins ;
} catch ( e ) {
Logger . stacktrace ( 'query error' , e ) ;
return null ;
}
}
cleanupDiscord ( ) {
ElectronDiscordModule . cleanupDisplaySleep ( ) ;
Dispatcher . wait ( ( ) => {
DiscordModules . ContextMenuActions . closeContextMenu ( ) ;
DiscordModules . ModalStack . popAll ( ) ;
DiscordModules . LayerManager . popAllLayers ( ) ;
DiscordModules . PopoutStack . closeAll ( ) ;
2020-01-12 18:38:14 +01:00
WebpackModules . getByProps ( 'openModal' ) . modalsApi . setState ( ( ) => ( { default : [ ] } ) ) ; /* slow? unsafe? async? */
2020-03-05 16:16:55 +01:00
if ( ! this . settings . useThirdStep ) DiscordModules . NavigationUtils . transitionTo ( '/channels/@me' ) ;
2020-01-08 00:17:36 +01:00
} ) ;
}
handleCrash ( _this , stack , isRender ) {
this . onCrashRecoveredDelayedCall . cancel ( ) ;
2020-03-05 16:16:55 +01:00
if ( this . _ _safeClearTimeout ) clearTimeout ( this . _ _safeClearTimeout ) , ( this . _ _safeClearTimeout = 0 ) ;
2020-01-12 18:38:14 +01:00
if ( ! isRender ) {
_this . setState ( {
error : { stack }
} ) ;
}
2020-01-08 00:17:36 +01:00
if ( ! this . notificationId ) {
this . notificationId = XenoLib . Notifications . danger ( 'Crash detected, attempting recovery' , { timeout : 0 , loading : true } ) ;
}
const responsiblePlugins = this . queryResponsiblePlugins ( stack ) ;
if ( responsiblePlugins && ! Array . isArray ( responsiblePlugins ) ) {
XenoLib . Notifications . update ( this . notificationId , { content : ` Failed to recover from crash, ${ responsiblePlugins . name } is not stopping properly ` , loading : false } ) ;
return ;
}
if ( ! this . attempts ) {
this . cleanupDiscord ( ) ;
if ( responsiblePlugins ) this . suspectedPlugin = responsiblePlugins . shift ( ) ;
}
if ( ! this . attempts && ! this . autoDisabledPlugins ) {
setTimeout ( ( ) => {
this . autoDisabledPlugins = Utilities . deepclone ( global . bdpluginErrors ) ;
if ( ! this . autoDisabledPlugins || ! this . autoDisabledPlugins . length ) {
return ;
}
this . suspectedPlugin2 = this . autoDisabledPlugins . shift ( ) . name ;
2020-03-31 21:31:22 +02:00
global . bdpluginErrors . splice ( 0 , global . bdpluginErrors . length ) ;
2020-01-08 00:17:36 +01:00
} , 750 ) ;
}
if ( this . setStateTimeout ) return ;
2020-03-05 16:16:55 +01:00
if ( this . attempts >= 10 || ( ( this . settings . useThirdStep ? this . attempts >= 3 : this . attempts >= 2 ) && ( ! responsiblePlugins || ! responsiblePlugins [ 0 ] ) ) ) {
2020-01-08 00:17:36 +01:00
XenoLib . Notifications . update ( this . notificationId , { content : 'Failed to recover from crash' , loading : false } ) ;
return ;
}
if ( this . attempts === 1 ) XenoLib . Notifications . update ( this . notificationId , { content : 'Failed, trying again' } ) ;
2020-03-05 16:16:55 +01:00
else if ( this . settings . useThirdStep && this . attempts === 2 ) {
Dispatcher . wait ( ( ) => DiscordModules . NavigationUtils . transitionTo ( '/channels/@me' ) ) ;
XenoLib . Notifications . update ( this . notificationId , { content : ` Failed, switching channels ` } ) ;
} else if ( this . attempts >= 2 ) {
2020-01-08 00:17:36 +01:00
try {
pluginModule . disablePlugin ( responsiblePlugins [ 0 ] ) ;
} catch ( e ) { }
XenoLib . Notifications . update ( this . notificationId , { content : ` Failed, suspecting ${ responsiblePlugins [ 0 ] } for recovery failure ` } ) ;
2020-01-10 11:09:26 +01:00
if ( ! this . disabledPlugins ) this . disabledPlugins = [ ] ;
2020-01-08 00:17:36 +01:00
this . disabledPlugins . push ( responsiblePlugins [ 0 ] ) ;
}
this . setStateTimeout = setTimeout ( ( ) => {
this . setStateTimeout = null ;
this . attempts ++ ;
this . onCrashRecoveredDelayedCall . delay ( ) ;
_this . setState ( {
error : null ,
info : null
} ) ;
} , 1000 ) ;
}
/* PATCHES */
patchAll ( ) {
this . patchErrorBoundary ( this . promises . state ) ;
}
patchErrorBoundary ( ) {
const ErrorBoundary = WebpackModules . getByDisplayName ( 'ErrorBoundary' ) ;
Patcher . instead ( ErrorBoundary . prototype , 'componentDidCatch' , ( _this , [ { message , stack } , { componentStack } ] , orig ) => {
this . handleCrash ( _this , stack ) ;
} ) ;
Patcher . after ( ErrorBoundary . prototype , 'render' , ( _this , _ , ret ) => {
if ( ! _this . state . error ) return ;
if ( ! this . notificationId ) {
this . handleCrash ( _this , _this . state . error . stack , true ) ;
}
2020-03-05 16:16:55 +01:00
/* better be safe than sorry! */
if ( ! _this . state . customPageError ) {
ret . props . action = React . createElement (
XenoLib . ReactComponents . ErrorBoundary ,
{ label : 'ErrorBoundary patch' , onError : ( ) => _this . setState ( { customPageError : true /* sad day.. */ } ) } ,
React . createElement (
Flex ,
{
grow : 0 ,
direction : Flex . Direction . HORIZONTAL
2020-01-08 00:17:36 +01:00
} ,
2020-03-05 16:16:55 +01:00
React . createElement (
XenoLib . ReactComponents . Button ,
{
size : XenoLib . ReactComponents . ButtonOptions . ButtonSizes . LARGE ,
style : {
marginRight : 20
} ,
onClick : ( ) => {
this . attempts = 0 ;
this . disabledPlugins = null ;
XenoLib . Notifications . update ( this . notificationId , { content : 'If you say so.. trying again' , loading : true } ) ;
_this . setState ( {
error : null ,
info : null
} ) ;
}
} ,
'Recover'
) ,
React . createElement (
XenoLib . ReactComponents . Button ,
{
size : XenoLib . ReactComponents . ButtonOptions . ButtonSizes . LARGE ,
style : {
marginRight : 20
} ,
onClick : ( ) => window . location . reload ( true )
} ,
'Reload'
)
)
) ;
}
2020-01-08 00:17:36 +01:00
ret . props . note = [
React . createElement ( 'div' , { } , 'Discord has crashed!' ) ,
this . suspectedPlugin ? React . createElement ( 'div' , { } , this . suspectedPlugin , this . suspectedPlugin2 && this . suspectedPlugin2 !== this . suspectedPlugin ? [ ' or ' , this . suspectedPlugin2 ] : false , ' is likely responsible for the crash' ) : this . suspectedPlugin2 ? React . createElement ( 'div' , { } , this . suspectedPlugin2 , ' is likely responsible for the crash' ) : React . createElement ( 'div' , { } , 'Plugin responsible for crash is unknown' ) ,
this . disabledPlugins && this . disabledPlugins . length
? React . createElement (
'div' ,
{ } ,
this . disabledPlugins . map ( ( e , i ) => ` ${ i === 0 ? '' : ', ' } ${ e } ` ) ,
this . disabledPlugins . length > 1 ? ' have' : ' has' ,
' been disabled in an attempt to recover'
)
: false ,
global . bdpluginErrors && global . bdpluginErrors . length ? React . createElement ( 'div' , { } , global . bdpluginErrors . length , ' plugins have been disabled by BBD due to the crash' ) : null
] ;
} ) ;
2020-03-05 16:16:55 +01:00
const ErrorBoundaryInstance = ReactTools . getOwnerInstance ( document . querySelector ( ` . ${ XenoLib . getSingleClass ( 'errorPage' ) } ` ) || document . querySelector ( '#app-mount > svg:first-of-type' ) , { include : [ 'ErrorBoundary' ] } ) ;
ErrorBoundaryInstance . state . customPageError = false ;
ErrorBoundaryInstance . forceUpdate ( ) ;
2020-01-08 00:17:36 +01:00
}
/* PATCHES */
2020-03-05 16:16:55 +01:00
showChangelog ( footer ) {
XenoLib . showChangelog ( ` ${ this . name } has been updated! ` , this . version , this . _config . changelog ) ;
}
2020-01-08 00:17:36 +01:00
getSettingsPanel ( ) {
return this . buildSettingsPanel ( ) . getElement ( ) ;
}
get [ Symbol . toStringTag ] ( ) {
return 'Plugin' ;
}
get css ( ) {
return this . _css ;
}
get name ( ) {
return config . info . name ;
}
get short ( ) {
let string = '' ;
for ( let i = 0 , len = config . info . name . length ; i < len ; i ++ ) {
const char = config . info . name [ i ] ;
if ( char === char . toUpperCase ( ) ) string += char ;
}
return string ;
}
get author ( ) {
return config . info . authors . map ( author => author . name ) . join ( ', ' ) ;
}
get version ( ) {
return config . info . version ;
}
get description ( ) {
return config . info . description ;
}
} ;
} ;
/* Finalize */
2020-03-05 16:16:55 +01:00
let ZeresPluginLibraryOutdated = false ;
let XenoLibOutdated = false ;
try {
if ( global . BdApi && 'function' == typeof BdApi . getPlugin ) {
const i = ( i , n ) => ( ( i = i . split ( '.' ) . map ( i => parseInt ( i ) ) ) , ( n = n . split ( '.' ) . map ( i => parseInt ( i ) ) ) , ! ! ( n [ 0 ] > i [ 0 ] ) || ! ! ( n [ 0 ] == i [ 0 ] && n [ 1 ] > i [ 1 ] ) || ! ! ( n [ 0 ] == i [ 0 ] && n [ 1 ] == i [ 1 ] && n [ 2 ] > i [ 2 ] ) ) ,
n = ( n , e ) => n && n . _config && n . _config . info && n . _config . info . version && i ( n . _config . info . version , e ) ,
e = BdApi . getPlugin ( 'ZeresPluginLibrary' ) ,
o = BdApi . getPlugin ( 'XenoLib' ) ;
2020-03-31 21:31:22 +02:00
n ( e , '1.2.14' ) && ( ZeresPluginLibraryOutdated = ! 0 ) , n ( o , '1.3.16' ) && ( XenoLibOutdated = ! 0 ) ;
2020-03-05 16:16:55 +01:00
}
} catch ( i ) {
console . error ( 'Error checking if libraries are out of date' , i ) ;
}
return ! global . ZeresPluginLibrary || ! global . XenoLib || ZeresPluginLibraryOutdated || XenoLibOutdated
2020-01-08 00:17:36 +01:00
? class {
2020-03-12 16:23:56 +01:00
constructor ( ) {
this . _XL _PLUGIN = true ;
2020-03-31 21:31:22 +02:00
this . start = this . load = this . handleMissingLib ;
2020-03-12 16:23:56 +01:00
}
2020-01-08 00:17:36 +01:00
getName ( ) {
return this . name . replace ( /\s+/g , '' ) ;
}
getAuthor ( ) {
return this . author ;
}
getVersion ( ) {
return this . version ;
}
getDescription ( ) {
2020-03-31 21:31:22 +02:00
return this . description + ' You are missing libraries for this plugin, please enable the plugin and click Download Now.' ;
2020-01-08 00:17:36 +01:00
}
stop ( ) { }
2020-03-31 21:31:22 +02:00
handleMissingLib ( ) {
const a = BdApi . findModuleByProps ( 'isModalOpenWithKey' ) ;
if ( a && a . isModalOpenWithKey ( ` ${ this . name } _DEP_MODAL ` ) ) return ;
2020-03-12 16:23:56 +01:00
const b = ! global . XenoLib ,
c = ! global . ZeresPluginLibrary ,
d = ( b && c ) || ( ( b || c ) && ( XenoLibOutdated || ZeresPluginLibraryOutdated ) ) ,
2020-03-05 16:16:55 +01:00
e = ( ( ) => {
2020-03-12 16:23:56 +01:00
let a = '' ;
return b || c ? ( a += ` Missing ${ XenoLibOutdated || ZeresPluginLibraryOutdated ? ' and outdated' : '' } ` ) : ( XenoLibOutdated || ZeresPluginLibraryOutdated ) && ( a += ` Outdated ` ) , ( a += ` ${ d ? 'Libraries' : 'Library' } ` ) , a ;
2020-03-05 16:16:55 +01:00
} ) ( ) ,
2020-03-12 16:23:56 +01:00
f = ( ( ) => {
let a = ` The ${ d ? 'libraries' : 'library' } ` ;
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 ;
} ) ( ) ,
g = BdApi . findModuleByProps ( 'push' , 'update' , 'pop' , 'popWithKey' ) ,
h = BdApi . findModuleByProps ( 'Sizes' , 'Weights' ) ,
i = BdApi . findModule ( a => a . defaultProps && a . key && 'confirm-modal' === a . key ( ) ) ,
2020-03-31 21:31:22 +02:00
j = ( ) => BdApi . alert ( e , BdApi . React . createElement ( 'span' , { } , BdApi . React . createElement ( 'div' , { } , f ) , ` Due to a slight mishap however, you'll have to download the libraries yourself. ` , c || ZeresPluginLibraryOutdated ? BdApi . React . createElement ( 'div' , { } , BdApi . React . createElement ( 'a' , { href : 'https://betterdiscord.net/ghdl?id=2252' , target : '_blank' } , 'Click here to download ZeresPluginLibrary' ) ) : null , b || XenoLibOutdated ? BdApi . React . createElement ( 'div' , { } , BdApi . React . createElement ( 'a' , { href : 'https://betterdiscord.net/ghdl?id=3169' , target : '_blank' } , 'Click here to download XenoLib' ) ) : null ) ) ;
2020-03-12 16:23:56 +01:00
if ( ! g || ! i || ! h ) return j ( ) ;
class k extends BdApi . React . PureComponent {
2020-03-05 16:16:55 +01:00
constructor ( a ) {
super ( a ) , ( this . state = { hasError : ! 1 } ) ;
}
2020-03-12 16:23:56 +01:00
componentDidCatch ( a ) {
2020-03-05 16:16:55 +01:00
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 ) ;
2020-02-03 17:34:05 +01:00
}
render ( ) {
2020-03-05 16:16:55 +01:00
return this . state . hasError ? null : this . props . children ;
2020-02-03 17:34:05 +01:00
}
}
2020-03-12 16:23:56 +01:00
class l extends i {
submitModal ( ) {
this . props . onConfirm ( ) ;
}
}
let m = ! 1 ;
const n = g . push (
a =>
2020-02-03 17:34:05 +01:00
BdApi . React . createElement (
2020-03-12 16:23:56 +01:00
k ,
{
label : 'missing dependency modal' ,
onError : ( ) => {
g . popWithKey ( n ) , j ( ) ;
}
} ,
BdApi . React . createElement (
l ,
Object . assign (
{
header : e ,
children : [ BdApi . React . createElement ( h , { color : h . Colors . PRIMARY , children : [ ` ${ f } Please click Download Now to download ${ d ? 'them' : 'it' } . ` ] } ) ] ,
red : ! 1 ,
confirmText : 'Download Now' ,
cancelText : 'Cancel' ,
onConfirm : ( ) => {
if ( m ) return ;
m = ! 0 ;
const a = require ( 'request' ) ,
b = require ( 'fs' ) ,
c = require ( 'path' ) ,
d = ( ) => {
2020-03-31 21:31:22 +02:00
( global . XenoLib && ! XenoLibOutdated ) || a ( 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/1XenoLib.plugin.js' , ( a , d , e ) => ( a || 200 !== d . statusCode ? ( g . popWithKey ( n ) , j ( ) ) : void b . writeFile ( c . join ( BdApi . Plugins . folder , '1XenoLib.plugin.js' ) , e , ( ) => { } ) ) ) ;
2020-02-03 17:34:05 +01:00
} ;
2020-03-31 21:31:22 +02:00
! global . ZeresPluginLibrary || ZeresPluginLibraryOutdated ? a ( 'https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js' , ( a , e , f ) => ( a || 200 !== e . statusCode ? ( g . popWithKey ( n ) , j ( ) ) : void ( b . writeFile ( c . join ( BdApi . Plugins . folder , '0PluginLibrary.plugin.js' ) , f , ( ) => { } ) , d ( ) ) ) ) : d ( ) ;
2020-03-12 16:23:56 +01:00
}
} ,
a
)
2020-02-03 17:34:05 +01:00
)
2020-03-12 16:23:56 +01:00
) ,
void 0 ,
` ${ this . name } _DEP_MODAL `
2020-03-05 16:16:55 +01:00
) ;
2020-01-08 00:17:36 +01:00
}
get [ Symbol . toStringTag ] ( ) {
return 'Plugin' ;
}
get name ( ) {
return config . info . name ;
}
get short ( ) {
let string = '' ;
for ( let i = 0 , len = config . info . name . length ; i < len ; i ++ ) {
const char = config . info . name [ i ] ;
if ( char === char . toUpperCase ( ) ) string += char ;
}
return string ;
}
get author ( ) {
return config . info . authors . map ( author => author . name ) . join ( ', ' ) ;
}
get version ( ) {
return config . info . version ;
}
get description ( ) {
return config . info . description ;
}
}
: buildPlugin ( global . ZeresPluginLibrary . buildPlugin ( config ) ) ;
} ) ( ) ;
/*@end@*/