dressed
Version:
A sleek, serverless-ready Discord bot framework.
65 lines (64 loc) • 1.98 kB
TypeScript
import type { APIApplicationCommandInteractionDataOption, APIAttachment, APIInteractionDataResolved, APIInteractionDataResolvedChannel, APIRole, APIUser } from "discord-api-types/v10";
import type { CommandInteraction } from "../../types/interaction.ts";
export interface OptionValueGetters<N> {
/**
* Get the option as a subcommand
*/
subcommand: () => {
/**
* Get an option from the subcommand
* @param name The name of the option
* @param required Whether the option is required
*/
getOption: CommandInteraction["getOption"];
name: N;
};
/**
* Get the option as a subcommand group
*/
subcommandGroup: () => {
/**
* Get a subcommand from the group
* @param name The name of the subcommand
*/
getSubcommand: <N extends string>(name: N) => ReturnType<OptionValueGetters<N>["subcommand"]> | undefined;
name: N;
};
/**
* Get the option as a string
*/
string: () => string;
/**
* Get the option as an integer
*/
integer: () => number;
/**
* Get the option as a boolean
*/
boolean: () => boolean;
/**
* Get the option as a user
*/
user: () => APIUser;
/**
* Get the option as a channel
*/
channel: () => APIInteractionDataResolvedChannel;
/**
* Get the option as a role
*/
role: () => APIRole;
/**
* Get the option as a mentionable
*/
mentionable: () => APIUser | APIRole;
/**
* Get the option as a number
*/
number: () => number;
/**
* Get the option as an attachment
*/
attachment: () => APIAttachment;
}
export declare function getOption<N extends string, R extends boolean>(name: N, required: R, options: APIApplicationCommandInteractionDataOption[], resolved?: APIInteractionDataResolved): R extends true ? OptionValueGetters<N> : OptionValueGetters<N> | undefined;