aboutsummaryrefslogtreecommitdiff
path: root/src/lib/utils/AllowedMentions.ts
blob: 7a377be0171d9a1810e91149e6bfae328f89d549 (plain)
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 { type MessageMentionOptions, type MessageMentionTypes } from 'discord.js';

export class AllowedMentions {
	public everyone: boolean;
	public users: boolean;
	public roles: boolean;

	public constructor(users = true, roles = false, everyone = false) {
		this.everyone = everyone;
		this.roles = roles;
		this.users = users;
	}

	public static none(): MessageMentionOptions {
		return { parse: [] };
	}

	public static all(): MessageMentionOptions {
		return {
			parse: ['everyone', 'roles', 'users']
		};
	}

	public static users(): MessageMentionOptions {
		return {
			parse: ['users']
		};
	}

	public static everyone(): MessageMentionOptions {
		return {
			parse: ['everyone']
		};
	}

	public static roles(): MessageMentionOptions {
		return {
			parse: ['roles']
		};
	}

	public toObject(): MessageMentionOptions {
		return {
			parse: [
				...(this.users ? ['users'] : []),
				...(this.roles ? ['roles'] : []),
				...(this.everyone ? ['everyone'] : [])
			] as MessageMentionTypes[]
		};
	}
}