-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
53 lines (44 loc) · 1.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const { React, getModuleByDisplayName } = require('powercord/webpack');
const { Plugin } = require('powercord/entities');
var { getModule } = require('powercord/webpack');
const Settings = require('./Settings.jsx');
module.exports = class PowerStatus extends Plugin {
startPlugin() {
if (!this.settings.get('statuses'))
this.settings.set('statuses', '');
if (!this.settings.get('delay'))
this.settings.set('delay', 2.5);
if (this.settings.get('enable') == null)
this.settings.set('enable', true);
powercord.api.settings.registerSettings('powerstatus', {
category: this.entityID,
label: 'Custom Status',
render: Settings
});
this.main();
}
pluginWillUnload () {
powercord.api.settings.unregisterSettings('powerstatus');
}
async main(statuses) {
var stats = this.settings.get('statuses');
var statuses = stats.split("\n");
if(statuses.length < 2)
return;
var delay = parseInt(this.settings.get('delay')) * 1000;
delay = delay < 1 ? 1 : delay;
var i = Math.round((new Date()).getTime() / delay) % statuses.length;
if(this.settings.get('enable'))
await this.setStatus(statuses[i]);
setTimeout(() => {
this.main(statuses);
}, delay);
}
async setStatus(text) {
require('powercord/webpack').getModule(['updateRemoteSettings'], false).updateRemoteSettings({
customStatus: {
text: text
}
});
}
}