BetterDiscordApp-v2/tests/plugins/Example/index.js

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-01-16 02:45:23 +01:00
module.exports = (Plugin, Api, Vendor) => {
const { $, moment, _ } = Vendor;
const { Events, Logger } = Api;
2018-01-16 02:45:23 +01:00
2018-02-12 16:20:27 +01:00
return class extends Plugin {
2018-01-16 02:45:23 +01:00
onStart() {
2018-02-12 00:04:07 +01:00
Events.subscribe('TEST_EVENT', this.eventTest);
Logger.log('onStart');
2018-02-12 16:20:27 +01:00
Logger.log(`Setting "default-0" value: ${this.getSetting('default-0')}`);
2018-02-13 17:26:20 +01:00
const exampleModule = new (Api.import('Example Module'));
Logger.log(`2+4=${exampleModule.add(2, 4)}`);
2018-01-31 09:32:20 +01:00
return true;
}
onStop() {
2018-02-12 00:04:07 +01:00
Events.unsubscribeAll();
Logger.log('onStop');
2018-01-23 14:19:55 +01:00
return true;
2018-01-16 02:45:23 +01:00
}
2018-02-12 00:04:07 +01:00
eventTest(e) {
Logger.log(e);
}
2018-02-12 16:20:27 +01:00
2018-02-12 23:49:44 +01:00
getExports() {
return {
test1: this.test1.bind(this),
test2: this.test2.bind(this)
};
}
test1() { return 'It works!'; }
test2() { return 'This works too!'; }
2018-02-12 16:20:27 +01:00
settingChanged(category, setting_id, value) {
if (!this.enabled) return;
Logger.log(`${category}/${setting_id} changed to ${value}`);
}
settingsChanged(settings) {
if (!this.enabled) return;
Logger.log([ 'Settings updated', settings ]);
}
2018-01-16 02:45:23 +01:00
}
2018-02-12 16:20:27 +01:00
}