aboutsummaryrefslogtreecommitdiff
path: root/src/lib/utils/AllowedMentions.ts
blob: b4b188dd0f23f6f33d62e8aaf05c8c6c63815890 (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
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[]
		};
	}
}