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

export const permissionTypeCaster: BushArgumentTypeCaster = (_, phrase) => {
	if (!phrase) return null;
	phrase = phrase.toUpperCase().replace(/ /g, '_');
	if (!Reflect.has(Permissions.FLAGS, phrase)) {
		return null;
	} else {
		return phrase;
	}
};