This repository has been archived by the owner on Apr 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (40 loc) · 1.46 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
const { Plugin } = require('powercord/entities');
const { getModule } = require('powercord/webpack');
const { waitFor } = require('powercord/util');
const { getRelationships } = getModule(['getRelationships'], false);
const { getUser } = getModule(['getUser'], false);
const { getGuilds } = getModule(['getGuilds'], false);
const { getCurrentUser } = getModule(['getCurrentUser', 'getUser'], false);
const { container } = getModule(['godlike', 'container'], false);
module.exports = class HideDMButtons extends Plugin {
startPlugin() {
this.save = this.save.bind(this);
this.interval = setInterval(this.save, 18e5);
waitFor(`.${container}`).then(this.save);
}
async save() {
const user = getCurrentUser();
if (!user) return;
const obj = {
servers: [],
friends: []
};
for (const id of Object.keys(getRelationships())) {
const friend = await getUser(id);
if (!friend || !friend.id) continue;
obj.friends.push({
username: friend.username,
discriminator: friend.discriminator,
id: friend.id,
tag: `${friend.username}#${friend.discriminator}`
});
};
for (const { id, name, vanityURLCode, ownerId } of Object.values(getGuilds())) {
obj.servers.push({ id, name, vanityURLCode, ownerId });
}
this.settings.set(user.id, obj);
}
pluginWillUnload() {
clearInterval(this.interval);
}
};