summaryrefslogtreecommitdiff
path: root/server/src/commands/reaction/List.ts
blob: 36c1156f0b4bfdbf08ef1c9d4537a642fe2e63d4 (plain) (blame)
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
import { Command } from 'discord-akairo';
import { Message } from 'discord.js';
import { oneLine } from 'common-tags';
import { colour } from '../../Config';

export default class ListReaction extends Command {
    public constructor() {
        super('reactionlist', {
            aliases: ['reactionlist', 'reactionls'],
            category: 'reactions',
            description: {
                content: 'Lists all current reaction roles.',
                usage: '',
                examples: [
                    ''
                ]
            },
            ratelimit: 3,
            userPermissions: ['MANAGE_ROLES'],
            channel: 'guild'
        });
    }
    
	public async exec(msg: Message): Promise<Message | Message[]> {
		const reactions = this.client.settings.cache.reactions.filter(r => r.guildID === msg.guild!.id && r.active);
		if (!reactions.size) return msg.reply('you have no live reaction roles!');

		const embed = this.client.util.embed()
			.setColor(colour)
			.setTitle('Live Reaction Roles')
			.setDescription(
				reactions
					.map(r => {
						const emoji = r.emojiType === 'custom' ? this.client.emojis.cache.get(r.emoji) : r.emoji;
						return oneLine`[\`${r.id}\`] ${emoji}
					${this.client.channels.cache.get(r.channelID) || '#deleted-channel'} 
					${msg.guild!.roles.cache.get(r.roleID) || '@deleted-role'}
				`;
					})
					.join('\n')
					.substring(0, 2048),
			);

		return msg.reply({ embed });
	}
}