Command Options
Options in Discord commands are required to have a description. Additionally, for all options, we can set whether they are required and include a function to transform their value.
Option Types
The possible types of options in a command are as follows:
Text
TypeScript autocomplete example
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createStringOption<R extends boolean, C extends SeyfertChoice<string>[] = SeyfertChoice<string>[], VC = never>(data: SeyfertStringOption<C, R, VC>): { readonly type: ApplicationCommandOptionType.String; readonly required?: R | undefined; readonly choices?: C | undefined; readonly value?: ValueCallback<ApplicationCommandOptionType.String, C, VC> | undefined; readonly description: string; readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"]; readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"]; readonly locales?: { name?: FlatObjectKeys<DefaultLocale>; description?: FlatObjectKeys<DefaultLocale>; }; readonly autocomplete?: AutocompleteCallback; readonly onAutocompleteError?: OnAutocompleteErrorCallback; readonly min_length?: number; readonly max_length?: number;}
createStringOption, class Command
Command, class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>
CommandContext } from 'seyfert';
const const options: { best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}
options = { /// Fixed choices best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number;}
best: createStringOption<boolean, [{ readonly name: "The best library"; readonly value: "seyfert";}, { readonly name: "An odd stuff"; readonly value: "meowdb";}], never>(data: SeyfertStringOption<[{ readonly name: "The best library"; readonly value: "seyfert";}, { readonly name: "An odd stuff"; readonly value: "meowdb";}], boolean, never>): { ...;}
createStringOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, [{ readonly name: "The best library"; readonly value: "seyfert"; }, { readonly name: "An odd stuff"; readonly value: "meowdb"; }], boolean, never>.choices?: [{ readonly name: "The best library"; readonly value: "seyfert";}, { readonly name: "An odd stuff"; readonly value: "meowdb";}] | undefined
choices: [ { name: "The best library"
name: 'The best library', value: "seyfert"
value: 'seyfert' }, { name: "An odd stuff"
name: 'An odd stuff', value: "meowdb"
value: 'meowdb' }, ] as type const = [{ readonly name: "The best library"; readonly value: "seyfert";}, { readonly name: "An odd stuff"; readonly value: "meowdb";}]
const, }),};
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options(const options: { best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}
options)class class Ping
Ping extends class Command
Command { async Ping.run(ctx: CommandContext<typeof options>): Promise<void>
run(ctx: CommandContext<{ best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}, never>
ctx: class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never>
CommandContext<typeof const options: { best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}
options>) { ctx: CommandContext<{ best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}, never>
ctx.CommandContext<{ best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; }; }, never>.options: ContextOptions<{ best: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: [...] | undefined; ... 8 more ...; readonly max_length?: number; };}>
options.best;best?: "seyfert" | "meowdb" | undefined
}}
Integers
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createIntegerOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertIntegerOption<C, R, VC>): { readonly type: ApplicationCommandOptionType.Integer; readonly required?: R | undefined; readonly choices?: C | undefined; readonly value?: ValueCallback<ApplicationCommandOptionType.Integer, C, VC> | undefined; readonly description: string; readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"]; readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"]; readonly locales?: { name?: FlatObjectKeys<DefaultLocale>; description?: FlatObjectKeys<DefaultLocale>; }; readonly autocomplete?: AutocompleteCallback; readonly onAutocompleteError?: OnAutocompleteErrorCallback; readonly min_value?: number; readonly max_value?: number;}
createIntegerOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ normal: { readonly type: ApplicationCommandOptionType.Integer; readonly required?: boolean | undefined; readonly choices?: SeyfertChoice<...>[] | undefined; ... 8 more ...; readonly max_value?: number;}
normal: createIntegerOption<boolean, SeyfertChoice<number>[], any>(data: SeyfertIntegerOption<SeyfertChoice<number>[], boolean, any>): { readonly type: ApplicationCommandOptionType.Integer; ... 10 more ...; readonly max_value?: number;}
createIntegerOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', }),
/// Fixed choices choices: { readonly type: ApplicationCommandOptionType.Integer; readonly required?: boolean | undefined; readonly choices?: { ...; }[] | undefined; ... 8 more ...; readonly max_value?: number;}
choices: createIntegerOption<boolean, { name: string; value: number;}[], any>(data: SeyfertIntegerOption<{ name: string; value: number;}[], boolean, any>): { readonly type: ApplicationCommandOptionType.Integer; ... 10 more ...; readonly max_value?: number;}
createIntegerOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', SeyfertBaseChoiceableOption<ApplicationCommandOptionType.Integer, { name: string; value: number; }[], boolean, any>.choices?: { name: string; value: number;}[] | undefined
choices: [ { name: string
name: 'seyfert', value: number
value: 1 }, { name: string
name: 'potocuit', value: number
value: 2 }, { name: string
name: 'biscuit', value: number
value: 3 } ] }),
/// Autocomplete autocomplete: { readonly type: ApplicationCommandOptionType.Integer; readonly required?: boolean | undefined; readonly choices?: SeyfertChoice<...>[] | undefined; ... 8 more ...; readonly max_value?: number;}
autocomplete: createIntegerOption<boolean, SeyfertChoice<number>[], any>(data: SeyfertIntegerOption<SeyfertChoice<number>[], boolean, any>): { readonly type: ApplicationCommandOptionType.Integer; ... 10 more ...; readonly max_value?: number;}
createIntegerOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', autocomplete?: AutocompleteCallback | undefined
autocomplete: (interaction: AutocompleteInteraction<boolean>
interaction) => { const const select: string[]
select = ['1651611', '4616165156549', '15616416515616'];
const const focus: string
focus = interaction: AutocompleteInteraction<boolean>
interaction.AutocompleteInteraction<boolean>.getInput(): string
getInput();
return interaction: AutocompleteInteraction<boolean>
interaction.AutocompleteInteraction<boolean>.respond(choices: APICommandAutocompleteInteractionResponseCallbackData["choices"]): Promise<undefined>
respond( const select: string[]
select .Array<string>.filter(predicate: (value: string, index: number, array: string[]) => unknown, thisArg?: any): string[] (+1 overload)
Returns the elements of an array that meet the condition specified in a callback function.
filter((ch: string
ch) => ch: string
ch.String.includes(searchString: string, position?: number): boolean
Returns true if searchString appears as a substring of the result of converting this
object to a String, at one or more positions that are
greater than or equal to position; otherwise, returns false.
includes(const focus: string
focus)) .Array<string>.map<{ name: string; value: number;}>(callbackfn: (value: string, index: number, array: string[]) => { name: string; value: number;}, thisArg?: any): { name: string; value: number;}[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((ch: string
ch) => ({ name: string
name: ch: string
ch, value: number
value: function parseInt(string: string, radix?: number): number
Converts a string to an integer.
parseInt(ch: string
ch) })) ); } }),
/// Value limits limitValue: { readonly type: ApplicationCommandOptionType.Integer; readonly required?: boolean | undefined; readonly choices?: SeyfertChoice<...>[] | undefined; ... 8 more ...; readonly max_value?: number;}
limitValue: createIntegerOption<boolean, SeyfertChoice<number>[], any>(data: SeyfertIntegerOption<SeyfertChoice<number>[], boolean, any>): { readonly type: ApplicationCommandOptionType.Integer; ... 10 more ...; readonly max_value?: number;}
createIntegerOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', max_value?: number | undefined
max_value: 500, min_value?: number | undefined
min_value: 200 })})class class Ping
Ping extends class Command
Command {}
Numbers
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createNumberOption<R extends boolean, C extends SeyfertChoice<number>[] = SeyfertChoice<number>[], VC = never>(data: SeyfertNumberOption<C, R, VC>): { readonly type: ApplicationCommandOptionType.Number; readonly required?: R | undefined; readonly choices?: C | undefined; readonly value?: ValueCallback<ApplicationCommandOptionType.Number, C, VC> | undefined; readonly description: string; readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"]; readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"]; readonly locales?: { name?: FlatObjectKeys<DefaultLocale>; description?: FlatObjectKeys<DefaultLocale>; }; readonly autocomplete?: AutocompleteCallback; readonly onAutocompleteError?: OnAutocompleteErrorCallback; readonly min_value?: number; readonly max_value?: number;}
createNumberOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ normal: { readonly type: ApplicationCommandOptionType.Number; readonly required?: boolean | undefined; readonly choices?: SeyfertChoice<...>[] | undefined; ... 8 more ...; readonly max_value?: number;}
normal: createNumberOption<boolean, SeyfertChoice<number>[], any>(data: SeyfertNumberOption<SeyfertChoice<number>[], boolean, any>): { readonly type: ApplicationCommandOptionType.Number; ... 10 more ...; readonly max_value?: number;}
createNumberOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: '', }),
// Same logic as integers but applies to all numbers, including decimals})class class Ping
Ping extends class Command
Command {}
Channels
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createChannelOption<R extends boolean, C extends keyof SeyfertChannelMap = keyof SeyfertChannelMap, VC = never>(data: SeyfertChannelOption<C, R, VC>): { readonly type: ApplicationCommandOptionType.Channel; readonly required?: R | undefined; readonly value?: ValueCallback<ApplicationCommandOptionType.Channel, C, VC> | undefined; readonly description: string; readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"]; readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"]; readonly locales?: { name?: FlatObjectKeys<DefaultLocale>; description?: FlatObjectKeys<DefaultLocale>; }; readonly channel_types?: C[] | undefined;}
createChannelOption, class Command
Command } from 'seyfert';import { ChannelType } from 'seyfert/lib/types';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ channel: { readonly type: ApplicationCommandOptionType.Channel; readonly required?: boolean | undefined; readonly value?: ValueCallback<...> | undefined; ... 4 more ...; readonly channel_types?: (keyof SeyfertChannelMap)[] | undefined;}
channel: createChannelOption<boolean, keyof SeyfertChannelMap, any>(data: SeyfertChannelOption<keyof SeyfertChannelMap, boolean, any>): { ...;}
createChannelOption({ description: string
description: '', }),
/// Specific channel type channelTypes: { readonly type: ApplicationCommandOptionType.Channel; readonly required?: boolean | undefined; readonly value?: ValueCallback<...> | undefined; ... 4 more ...; readonly channel_types?: ChannelType.GuildVoice[] | undefined;}
channelTypes: createChannelOption<boolean, ChannelType.GuildVoice, any>(data: SeyfertChannelOption<ChannelType.GuildVoice, boolean, any>): { readonly type: ApplicationCommandOptionType.Channel; ... 6 more ...; readonly channel_types?: ChannelType.GuildVoice[] | undefined;}
createChannelOption({ description: string
description: 'This is a limited channel option', channel_types?: ChannelType.GuildVoice[] | undefined
channel_types: [ChannelType.function (enum member) ChannelType.GuildVoice = 2
A voice channel within a guild
GuildVoice] })})class class Ping
Ping extends class Command
Command {}
Booleans
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createBooleanOption<R extends boolean, T extends SeyfertBooleanOption<R> = SeyfertBooleanOption<R>>(data: T): T & { readonly type: ApplicationCommandOptionType.Boolean;}
createBooleanOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ bool: { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Boolean;}
bool: createBooleanOption<boolean, { description: string; required: true;}>(data: { description: string; required: true;}): { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Boolean;}
createBooleanOption({ description: string
description: 'This is a boolean option', required: true
required: true })})class class Ping
Ping extends class Command
Command {}
Users
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createUserOption<R extends boolean, T extends SeyfertUserOption<R> = SeyfertUserOption<R>>(data: T): T & { readonly type: ApplicationCommandOptionType.User;}
createUserOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ user: { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.User;}
user: createUserOption<boolean, { description: string; required: true;}>(data: { description: string; required: true;}): { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.User;}
createUserOption({ description: string
description: 'This is a user option', required: true
required: true })})class class Ping
Ping extends class Command
Command {}
Roles
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createRoleOption<R extends boolean, T extends SeyfertRoleOption<R> = SeyfertRoleOption<R>>(data: T): T & { readonly type: ApplicationCommandOptionType.Role;}
createRoleOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ role: { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Role;}
role: createRoleOption<boolean, { description: string; required: true;}>(data: { description: string; required: true;}): { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Role;}
createRoleOption({ description: string
description: 'This is a role option', required: true
required: true })})class class Ping
Ping extends class Command
Command {}
Mentionables
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createMentionableOption<R extends boolean, T extends SeyfertMentionableOption<R> = SeyfertMentionableOption<R>>(data: T): T & { readonly type: ApplicationCommandOptionType.Mentionable;}
createMentionableOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ mentionable: { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Mentionable;}
mentionable: createMentionableOption<boolean, { description: string; required: true;}>(data: { description: string; required: true;}): { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Mentionable;}
createMentionableOption({ description: string
description: 'This is a mentionable option', required: true
required: true })})class class Ping
Ping extends class Command
Command {}
Attachments
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createAttachmentOption<R extends boolean, T extends SeyfertAttachmentOption<R> = SeyfertAttachmentOption<R>>(data: T): T & { readonly type: ApplicationCommandOptionType.Attachment;}
createAttachmentOption, class Command
Command } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ attachment: { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Attachment;}
attachment: createAttachmentOption<boolean, { description: string; required: true;}>(data: { description: string; required: true;}): { description: string; required: true;} & { readonly type: ApplicationCommandOptionType.Attachment;}
createAttachmentOption({ description: string
description: 'This is an attachment option', required: true
required: true })})class class Ping
Ping extends class Command
Command {}
Transforming the Value
We can transform the value of any option using the value
method, which takes the data value and two functions: ok
and fail
.
import { function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options, function createStringOption<R extends boolean, C extends SeyfertChoice<string>[] = SeyfertChoice<string>[], VC = never>(data: SeyfertStringOption<C, R, VC>): { readonly type: ApplicationCommandOptionType.String; readonly required?: R | undefined; readonly choices?: C | undefined; readonly value?: ValueCallback<ApplicationCommandOptionType.String, C, VC> | undefined; readonly description: string; readonly description_localizations?: APIApplicationCommandBasicOption["description_localizations"]; readonly name_localizations?: APIApplicationCommandBasicOption["name_localizations"]; readonly locales?: { name?: FlatObjectKeys<DefaultLocale>; description?: FlatObjectKeys<DefaultLocale>; }; readonly autocomplete?: AutocompleteCallback; readonly onAutocompleteError?: OnAutocompleteErrorCallback; readonly min_length?: number; readonly max_length?: number;}
createStringOption, class Command
Command } from 'seyfert';import type { type OKFunction<T> = (value: T) => void
OKFunction } from 'seyfert';
@function Options(options: (new () => SubCommand)[] | OptionsRecord): <T extends { new (...args: any[]): object;}>(target: T) => { new (...args: any[]): { options: SubCommand[] | CommandOption[]; };} & T
Options({ url: { readonly type: ApplicationCommandOptionType.String; readonly required?: boolean | undefined; readonly choices?: SeyfertChoice<...>[] | undefined; ... 8 more ...; readonly max_length?: number;}
url: createStringOption<boolean, SeyfertChoice<string>[], URL>(data: SeyfertStringOption<SeyfertChoice<string>[], boolean, URL>): { readonly type: ApplicationCommandOptionType.String; ... 10 more ...; readonly max_length?: number;}
createStringOption({ SeyfertBaseChoiceableOption<T extends keyof ReturnOptionsTypes, C = T extends ChoiceableTypes ? SeyfertChoice<ChoiceableValues[T]>[] : never, R = boolean, VC = never>.description: string
description: 'how to be a gamer',
SeyfertBaseChoiceableOption<ApplicationCommandOptionType.String, SeyfertChoice<string>[], boolean, URL>.value?: ValueCallback<ApplicationCommandOptionType.String, SeyfertChoice<string>[], URL> | undefined
value(data: { context: CommandContext; value: string;}
data, ok: OKFunction<URL>
ok: type OKFunction<T> = (value: T) => void
OKFunction<interface URL
URL
class is a global reference for import { URL } from 'url'
https://nodejs.org/api/url.html#the-whatwg-url-api
URL>, fail: StopFunction
fail) { if (function isUrl(url: string): boolean
isUrl(data: { context: CommandContext; value: string;}
data.value: string
value)) return ok: (value: URL) => void
ok(new var URL: new (input: string | { toString: () => string;}, base?: string | URL) => URL
URL
class is a global reference for import { URL } from 'url'
https://nodejs.org/api/url.html#the-whatwg-url-api
URL(data: { context: CommandContext; value: string;}
data.value: string
value)); fail: (error: string) => void
fail('expected a valid url'); } })})class class Ping
Ping extends class Command
Command {}
Now, the command’s option value is of type URL
. If it’s not valid, an error will be thrown.
Refer to Creating Your First Command for a detailed example of enabling autocomplete.