aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/permission.ts
blob: 4ae632751a046b6d71a438b20305ec7dc47fa6dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { type BushArgumentTypeCaster } from '#lib';
import { Permissions, type PermissionString } from 'discord.js';

export const permission: BushArgumentTypeCaster<PermissionString | null> = (_, phrase) => {
	if (!phrase) return null;
	phrase = phrase.toUpperCase().replace(/ /g, '_');
	if (!(phrase in Permissions.FLAGS)) {
		return null;
	} else {
		return phrase as PermissionString;
	}
};