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

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