/
emojis.js
47 lines (39 loc) · 1.05 KB
/
emojis.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
import debug from 'debug';
import chalk from 'chalk';
import aquarius from '../../aquarius';
import { TEN_MINUTES } from '../helpers/times';
const log = debug('Emoji Manager');
/**
* Manages custom emoji for Aquarius
* @extends Map
*/
export default class EmojiManager extends Map {
/**
* Registers handlers to run once Aquarius has logged on and
* loads information on boot.
*/
initialize() {
log('Creating List');
this.getList();
setInterval(() => this.getList(), TEN_MINUTES);
}
/**
* Refreshes Map state with uploaded emojis in the Home Guild
*/
getList() {
log('Refreshing emoji list');
const homeGuild = aquarius.guilds.get(aquarius.config.home.guild);
if (!homeGuild) {
log(
chalk.redBright(
'ERROR: Aquarius is not a member of the Home Server defined in `config.yml`'
)
);
return;
}
homeGuild.emojis
.filter(emoji => emoji.name.startsWith('aquarius'))
.array()
.forEach(emoji => this.set(emoji.name.replace(/aquarius_/, ''), emoji));
}
}