aboutsummaryrefslogtreecommitdiff
path: root/src/commands/dev/testDuration.ts
blob: 2d636d236e8656f8d8798c1039d7f601955c1a39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { BushCommand, BushSlashMessage } from '@lib';
import { stripIndents } from 'common-tags';
import { Message } from 'discord.js';

export default class TestDurationCommand extends BushCommand {
	public constructor() {
		super('testduration', {
			aliases: ['testduration'],
			category: 'dev',
			description: {
				content: 'Tests duration parsing.',
				usage: 'testduration [reason]',
				examples: ['testduration']
			},
			args: [
				{
					id: 'reason',
					type: 'contentWithDuration',
					match: 'rest',
					prompt: {
						start: 'Enter text and a duration here.',
						retry: '{error} Error parsing duration and text.',
						optional: true
					}
				}
			],
			slash: true,
			slashOptions: [
				{
					name: 'reason',
					description: 'Enter text and a duration here.',
					type: 'STRING',
					required: false
				}
			],
			hidden: true,
			ownerOnly: true
		});
	}

	async exec(
		message: Message | BushSlashMessage,
		{ reason }: { reason?: { duration: number; contentWithoutTime: string } }
	): Promise<unknown> {
		const rawDuration = reason.duration;
		const text = reason.contentWithoutTime;
		const humanizedDuration = this.client.util.humanizeDuration(rawDuration);
		return await message.util.reply(stripIndents`
		**rawDuration:** ${rawDuration}
		**text:** ${text}
		**humanizedDuration:** ${humanizedDuration}`);
	}
}