BetterDiscordApp-v2/client/src/modules/modulemanager.js

39 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-02-01 03:36:47 +01:00
/**
* BetterDiscord Module Manager
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
* All rights reserved.
* https://betterdiscord.net
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/*Module Manager initializes all modules when everything is ready*/
2018-02-13 20:56:01 +01:00
import { Events, SocketProxy, EventHook, CssEditor } from 'modules';
2018-02-01 03:36:47 +01:00
import { ProfileBadges } from 'ui';
export default class {
static get modules() {
2018-02-01 04:00:28 +01:00
return this._modules ? this._modules : (this._modules = [
2018-02-02 13:45:06 +01:00
new ProfileBadges(),
new SocketProxy(),
2018-02-13 20:56:01 +01:00
new EventHook(),
CssEditor
2018-02-01 04:00:28 +01:00
]);
2018-02-01 03:36:47 +01:00
}
2018-02-02 13:45:06 +01:00
static async initModules() {
2018-02-01 03:36:47 +01:00
for (let module of this.modules) {
try {
if (module.init && module.init instanceof Function) module.init();
} catch (err) {
console.log(`Failed to initialize module: ${err}`);
}
}
2018-02-02 13:45:06 +01:00
return true;
2018-02-01 03:36:47 +01:00
}
}