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

export class AllowedMentions {
	public everyone: boolean;
	public users: boolean;
	public roles: boolean;
	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 constructor(users = true, roles = false, everyone = false) {
		this.everyone = everyone;
		this.roles = roles;
		this.users = users;
	}

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