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

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