-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdisableEmotes.js
More file actions
51 lines (45 loc) · 1.36 KB
/
disableEmotes.js
File metadata and controls
51 lines (45 loc) · 1.36 KB
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
import eventManager from 'src/utils/eventManager.js';
import * as settings from 'src/utils/settings/index.js';
import { global, globalSet } from 'src/utils/global.js';
import Translation from 'src/structures/constants/translation';
import compound from 'src/utils/compoundEvent';
const baseSetting = {
key: 'underscript.emotes.disable',
page: 'Chat',
category: Translation.Setting('category.chat.emotes'),
};
const originalEmotes = [{
id: 0,
image: '',
name: '',
ucpCost: 0,
code: '::',
}];
originalEmotes.shift();
function init() {
originalEmotes.push(...global('chatEmotes'));
makeSettings();
updateEmotes();
}
const EmojiName = Translation.Setting('emote.disable', 1);
function makeSettings() {
originalEmotes.forEach((emote) => {
const setting = {
...baseSetting,
name: `<img height="32px" src="images/emotes/${emote.image}.png"/> ${EmojiName.translate(emote.name)}`,
onChange: updateEmotes,
};
setting.key += `.${emote.id}`;
settings.register(setting);
});
}
function updateEmotes() {
if (!originalEmotes.length) return;
const filtered = originalEmotes.filter(({ id }) => !settings.value(`${baseSetting.key}.${id}`));
globalSet('chatEmotes', filtered);
globalSet('gameEmotes', filtered, {
throws: false,
});
}
compound('Chat:Connected', 'underscript:ready', init);
eventManager.on('connect', updateEmotes);