forked from neplextech/commandkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.subcommand.ts
More file actions
47 lines (43 loc) · 1.46 KB
/
deploy.subcommand.ts
File metadata and controls
47 lines (43 loc) · 1.46 KB
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
import { ApplicationCommandOptionType } from 'discord.js';
import {
ChatInputCommandContext,
CommandData,
MessageCommandContext,
} from 'commandkit';
import { replyWithHierarchyDemo } from '@/utils/hierarchical-demo';
export const command: CommandData = {
name: 'deploy',
description: 'Run a folder-based direct subcommand under the root.',
options: [
{
name: 'environment',
description: 'Where the deployment should go',
type: ApplicationCommandOptionType.String,
required: false,
choices: [
{ name: 'staging', value: 'staging' },
{ name: 'production', value: 'production' },
],
},
{
name: 'dry_run',
description: 'Whether to simulate the deployment',
type: ApplicationCommandOptionType.Boolean,
required: false,
},
],
};
async function execute(ctx: ChatInputCommandContext | MessageCommandContext) {
const environment = ctx.options.getString('environment') ?? 'staging';
const dryRun = ctx.options.getBoolean('dry_run') ?? true;
return replyWithHierarchyDemo(ctx, {
title: 'Ops Deploy',
shape: 'root command -> direct subcommand',
leafStyle: 'folder leaf ([deploy]/command.ts)',
summary:
'Shows a direct folder-based subcommand with middleware scoped only to the leaf directory, plus the same prefix route syntax.',
details: [`environment: ${environment}`, `dry_run: ${dryRun}`],
});
}
export const chatInput = execute;
export const message = execute;