oceanic.js
Version:
A NodeJS library for interfacing with Discord.
114 lines (113 loc) • 6.75 kB
TypeScript
import type { ModalSubmitChannelSelectComponent, ModalSubmitComponents, ModalSubmitComponentsActionRow, ModalSubmitComponentsLabel, ModalSubmitFileUploadComponent, ModalSubmitInteractionResolvedData, ModalSubmitMentionableSelectComponent, ModalSubmitRoleSelectComponent, ModalSubmitStringSelectComponent, ModalSubmitTextInputComponent, ModalSubmitUserSelectComponent } from "../../types/interactions";
import type Role from "../../structures/Role";
import type User from "../../structures/User";
import type InteractionResolvedChannel from "../../structures/InteractionResolvedChannel";
import type Attachment from "../../structures/Attachment";
/** A wrapper for interaction components. */
export default class ModalSubmitInteractionComponentsWrapper {
/** The raw components from Discord. */
raw: Array<ModalSubmitComponentsActionRow | ModalSubmitComponentsLabel>;
resolved: ModalSubmitInteractionResolvedData;
constructor(resolved: ModalSubmitInteractionResolvedData, data: Array<ModalSubmitComponentsActionRow | ModalSubmitComponentsLabel>);
private _getComponent;
/**
* Get a channel select option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getChannelSelectComponent(name: string, required?: false): ModalSubmitChannelSelectComponent | undefined;
getChannelSelectComponent(name: string, required: true): ModalSubmitChannelSelectComponent;
/**
* Get the values of a channel select option. This always returns an array, since selects can be multi-choice.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getChannelSelectValues(name: string, required?: false): Array<InteractionResolvedChannel> | undefined;
getChannelSelectValues(name: string, required: true): Array<InteractionResolvedChannel>;
/** Get the components in this interaction. */
getComponents(): Array<ModalSubmitComponents>;
/**
* Get a file upload option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getFileUploadComponent(name: string, required?: false): ModalSubmitFileUploadComponent | undefined;
getFileUploadComponent(name: string, required: true): ModalSubmitFileUploadComponent;
/**
* Get the values of a file upload option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getFileUploadValues(name: string, required?: false): Array<Attachment> | undefined;
getFileUploadValues(name: string, required: true): Array<Attachment>;
/**
* Get a mentionable select option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getMentionableSelectComponent(name: string, required?: false): ModalSubmitMentionableSelectComponent | undefined;
getMentionableSelectComponent(name: string, required: true): ModalSubmitMentionableSelectComponent;
/**
* Get the values of a mentionable select option. This always returns an array, since selects can be multi-choice.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getMentionableSelectValues(name: string, required?: false): Array<User | Role> | undefined;
getMentionableSelectValues(name: string, required: true): Array<User | Role>;
/**
* Get a role select option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getRoleSelectComponent(name: string, required?: false): ModalSubmitRoleSelectComponent | undefined;
getRoleSelectComponent(name: string, required: true): ModalSubmitRoleSelectComponent;
/**
* Get the values of a role select option. This always returns an array, since selects can be multi-choice.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getRoleSelectValues(name: string, required?: false): Array<Role> | undefined;
getRoleSelectValues(name: string, required: true): Array<Role>;
/**
* Get a string select option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getStringSelectComponent(name: string, required?: false): ModalSubmitStringSelectComponent | undefined;
getStringSelectComponent(name: string, required: true): ModalSubmitStringSelectComponent;
/**
* Get the values of a string select option. This always returns an array, since selects can be multi-choice.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getStringSelectValues<T extends Array<string> = Array<string>>(name: string, required?: false): T | undefined;
getStringSelectValues<T extends Array<string> = Array<string>>(name: string, required: true): T;
/**
* Get a text input option value.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getTextInput<T extends string = string>(name: string, required?: false): T | undefined;
getTextInput<T extends string = string>(name: string, required: true): T;
/**
* Get a text input option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getTextInputComponent(name: string, required?: false): ModalSubmitTextInputComponent | undefined;
getTextInputComponent(name: string, required: true): ModalSubmitTextInputComponent;
/**
* Get a user select option.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getUserSelectComponent(name: string, required?: false): ModalSubmitUserSelectComponent | undefined;
getUserSelectComponent(name: string, required: true): ModalSubmitUserSelectComponent;
/**
* Get the values of a user select option. This always returns an array, since selects can be multi-choice.
* @param name The name of the option.
* @param required If true, an error will be thrown if the option is not present.
*/
getUserSelectValues(name: string, required?: false): Array<User> | undefined;
getUserSelectValues(name: string, required: true): Array<User>;
}