This repository has been archived by the owner on Aug 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
63 lines (52 loc) · 1.52 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
54
55
56
57
58
59
60
61
62
63
const {getModule} = require('powercord/webpack');
const {inject, uninject} = require('powercord/injector');
const {Plugin} = require('powercord/entities');
module.exports = class DefaultReplyPing extends Plugin {
async startPlugin() {
this.injectReplies();
powercord.api.settings.registerSettings('DRP', {
category: this.entityID,
label: 'Default Reply Ping',
render: require('./Settings.jsx'),
});
}
pluginWillUnload() {
uninject('drp-pending-reply');
powercord.api.settings.unregisterSettings('DRP');
}
async injectReplies() {
const module = await getModule(['createPendingReply']);
const guildStoreModule = await getModule(['getLastSelectedGuildId']);
const currentUserModule = await getModule(['getCurrentUser']);
inject(
'drp-pending-reply',
module,
'createPendingReply',
reply => {
if (!reply || !reply[0]) return;
const currentGuild = guildStoreModule.getGuildId();
const currentUser = currentUserModule.getCurrentUser().id;
const replyUser = reply[0].message?.author?.id;
const defaultSetting = this.settings.get('default', true);
const isGuildOverride =
currentGuild &&
this.settings
.get('override', '')
.split(' ')
.includes(currentGuild);
const isCurrentUser = currentUser == replyUser;
let result = defaultSetting;
if (isCurrentUser) {
result = false;
} else {
if (isGuildOverride) {
result = !defaultSetting;
}
}
reply[0].shouldMention = result;
return reply;
},
true,
);
}
};