aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/roleWithDuation.ts
blob: 423e7df84189f9cd285475e2e1e4c3da9b54e155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import { BushArgumentTypeCaster } from '@lib';

export const roleWithDurationTypeCaster: BushArgumentTypeCaster = async (
	message,
	phrase
): Promise<{ duration: number; role: string | null } | null> => {
	const { duration, contentWithoutTime } = client.util.parseDuration(phrase);
	if (contentWithoutTime === null || contentWithoutTime === undefined) return null;
	const role = await util.arg.cast('role', client.commandHandler.resolver, message, contentWithoutTime);
	console.debug(['role'], [role], [contentWithoutTime]);
	if (!role) return null;
	return { duration, role };
};