Base module

This commit is contained in:
Jiiks 2018-01-10 22:25:27 +02:00
parent a6d2e200f6
commit ba0ba4b2ce
3 changed files with 40 additions and 11 deletions

View File

@ -7,17 +7,15 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
const { Module } = require('./modulebase');
const { ipcMain } = require('electron');
class BDIpcEvent {
class BDIpcEvent extends Module {
constructor(event, args) {
this.bindings();
super(args);
this.ipcEvent = event;
this.args = args;
this.__eid = args.__eid;
delete this.args.__eid;
}
bindings() {
@ -26,8 +24,7 @@ class BDIpcEvent {
}
send(message) {
console.log(this.__eid);
this.ipcEvent.sender.send(this.__eid, message);
this.ipcEvent.sender.send(this.args.__eid, message);
}
reply(message) {

View File

@ -8,11 +8,9 @@
* LICENSE file in the root directory of this source tree.
*/
class Config {
const { Module } = require('./modulebase');
constructor(args) {
this.args = args;
}
class Config extends Module {
get version() {
return this.args.version;

View File

@ -0,0 +1,34 @@
/**
* BetterDiscord Module Base
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
* All rights reserved.
* https://github.com/JsSucks - 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.
*/
/*Base Module that every non-static module should extend*/
class Module {
constructor(args) {
this.__ = {
state: args,
args
}
this.init();
}
init() {
if (this.bindings) this.bindings();
if (this.setInitialState) this.setInitialState(this.state);
}
set args(t) {}
get args() { return this.__.args; }
get state() { return this.__.state; }
}
module.exports = { Module };