-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
28 lines (25 loc) · 1.06 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
const { Plugin } = require('powercord/entities');
const { getModule } = require('powercord/webpack');
const { inject, uninject } = require('powercord/injector');
module.exports = class NoEmoteColon extends Plugin {
async startPlugin () {
// messages webpack module is gay, need to import it manually
const messages = await getModule([ 'sendMessage', 'editMessage', 'deleteMessage' ]);
const emojiStore = await getModule([ 'getGuildEmoji' ]);
const guildsStore = await getModule([ 'getSortedGuilds' ]);
inject('noEmoteColon-msg', messages, 'sendMessage', (args) => {
const emotes = guildsStore.getSortedGuilds().map(g => g.guild).map(g => emojiStore.getGuildEmoji(g.id)).flat();
args[1].content = args[1].content.split(' ').map(word => {
const emote = emotes.find(e => e.name === word);
if (emote) {
return `<${emote.animated ? 'a' : ''}:${emote.name}:${emote.id}>`;
}
return word;
}).join(' ');
return args;
}, true);
}
pluginWillUnload () {
uninject('noEmoteColon-msg');
}
};