aboutsummaryrefslogtreecommitdiff
path: root/src/arguments/duration.ts
blob: f8b6ab17ca059e57a3ab33575a894afa27e2b9c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { BushArgumentTypeCaster } from '../lib/extensions/discord-akairo/BushArgumentTypeCaster';
import { BushMessage } from '../lib/extensions/discord.js/BushMessage';

export const durationTypeCaster: BushArgumentTypeCaster = (_message: BushMessage, phrase): number => {
	// if (!phrase) return null;
	// const regexString = Object.entries(BushConstants.TimeUnits)
	// 	.map(([name, { label }]) => String.raw`(?:(?<${name}>-?(?:\d+)?\.?\d+) *${label})?`)
	// 	.join('\\s*');
	// const match = new RegExp(`^${regexString}$`, 'im').exec(phrase);
	// if (!match) return null;
	// let milliseconds = 0;
	// for (const key in match.groups) {
	// 	const value = Number(match.groups[key] || 0);
	// 	milliseconds += value * BushConstants.TimeUnits[key].value;
	// }
	// return milliseconds;

	return client.util.parseDuration(phrase).duration;
};