darkcord
Version:
A NodeJS Package to interact with Discord API
516 lines • 16.4 kB
TypeScript
import { AnyClient, DataWithClient, InteractionFlags, MessagePostData } from "../types/index";
import { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandInteraction, APIApplicationCommandInteractionDataBasicOption, APIApplicationCommandInteractionDataOption, APIApplicationCommandOptionChoice, APIChannel, APIChatInputApplicationCommandInteractionData, APIInteraction, APIInteractionDataResolved, APIInteractionDataResolvedGuildMember, APIInteractionGuildMember, APIMessageApplicationCommandInteractionData, APIMessageComponentInteraction, APIMessageSelectMenuInteractionData, APIModalInteractionResponseCallbackData, APIModalSubmitInteraction, APIRole, APIUser, APIUserApplicationCommandInteractionData, ApplicationCommandOptionType, ApplicationCommandType, ComponentType, InteractionType, ModalSubmitActionRowComponent } from "discord-api-types/v10";
import { InteractionResponse } from "@darkcord/interactions";
import { Base } from "./Base";
import { Channel } from "./Channel";
import { Guild } from "./Guild";
import { Member } from "./Member";
import { Message } from "./Message";
import { Role } from "./Role";
import { User } from "./User";
export declare class Interaction<HttpPartial extends boolean = false> extends Base {
/**
* Id of the application this interaction is for
*/
applicationId: string;
/**
* Type of interaction
*/
type: InteractionType;
/**
* Continuation token for responding to the interaction
*/
token: string;
/**
* Read-only property, always 1
*/
version: number;
/**
* Member of the invoked command
*/
member: HttpPartial extends true ? APIInteractionGuildMember | null : Member | null;
/**
* User of the invoked command
*/
user: User | APIUser | null;
/**
* The guild id it was sent from
*/
guildId?: string;
/**
* The guild object it was sent from
*/
guild?: Guild | null;
/**
* The channel it was sent from
*/
channel?: Channel | (Partial<APIChannel> & Pick<APIChannel, "id" | "type">);
/**
* The channel id it was sent from
* @deprecated use `channel.id` instead
*/
channelId?: string;
rawData: APIInteraction;
constructor(data: DataWithClient<APIInteraction>);
static from(data: DataWithClient<APIInteraction>, res?: InteractionResponse): Interaction<false>;
isCommand(): this is CommandInteraction;
isComponent(): this is ComponentInteraction;
isAutoComplete(): this is AutocompleteInteraction;
isModalSubmit(): this is ModalSubmitInteraction;
toJSON(): any;
}
export declare class ReplyableInteraction extends Interaction {
_http?: InteractionResponse;
/**
* This interaction is received for webserver
*/
isHTTP: boolean;
/**
* The interaction is acknowledged
*/
acknowledged: boolean;
channel: Channel | (Partial<APIChannel> & Pick<APIChannel, "type" | "id">);
channelId: string;
constructor(data: DataWithClient<APIInteraction>, httpResponse?: InteractionResponse);
/**
* Respond to this interaction with defer
*/
defer(flags?: InteractionFlags): Promise<void>;
/**
* Delete a interaction reply
* @param messageId id of the reply to be deleted
* @returns
*/
deleteReply(messageId: string): Promise<void>;
/**
* Delete the original reply of this interaction
* @returns
*/
deleteOriginalReply(): Promise<void>;
/**
* Respond to this interaction
* @param content The content of response
*/
reply(content: MessagePostData | string): Promise<void>;
/**
* Edit a interaction reply
* @param messageId
* @param content
*/
editReply(messageId: string, content: MessagePostData | string): Promise<void>;
/**
* Edit the original reply of this interaction
* @param content
* @returns
*/
editOriginalReply(content: MessagePostData): Promise<void>;
/**
* Create a followup message for the original reply of this interaction
* @param content
* @returns
*/
createFollowUp(content: MessagePostData): Promise<void>;
/**
* Delete a followup message
* @param messageId The id of the followup to be deleted
* @returns
*/
deleteFollowUp(messageId: string): Promise<void>;
/**
* Edit a followup message
* @param messageId The id of the followup to be edited
* @param content The new content of followup
* @returns
*/
editFollowUp(messageId: string, content: MessagePostData): Promise<Message>;
/**
* Get a followup message
* @param messageId The id of the followup
* @returns
*/
getFollowUp(messageId: string): Promise<Message>;
/**
* Get the original reply of this interaction
* @returns
*/
getOriginalReply(): Promise<Message>;
toJSON(): {
readonly createdAt: number;
id: string;
rawData: APIInteraction;
type: number;
version: number;
token: string;
applicationId: string;
acknowledged: boolean;
};
}
export declare class SelectMenuInteractionValues {
#private;
_client: AnyClient;
guild?: Guild | null | undefined;
_rawValues: string[];
constructor(resolved: APIInteractionDataResolved | null, values: string[], _client: AnyClient, guild?: Guild | null | undefined);
_get<T extends Channel | User | Member | Role | APIUser | APIRole>(fn: (s: string) => T | undefined): T[];
/**
* Get the selected channels
* @returns
*/
channels(): Channel[];
/**
* Get the selected users
* @returns
*/
users(): User[];
/**
* Get the selected members
* @returns
*/
members(): Member[];
/**
* Get the selected roles
* @returns
*/
roles(): Role[];
/**
* Get the selected mentionables (roles, channels, users, members)
* @returns
*/
mentionables(): (User | Channel | Role | Member)[];
/**
* Get the selected strings
* @returns
*/
strings(): string[];
}
export declare class SelectMenuInteractionData {
/**
* The type of the component
*/
componentType: ComponentType;
/**
* The custom_id of the component
*/
customId: string;
/**
* Resolved data of the select menu
*/
resolved: APIInteractionDataResolved | null;
/**
* Values of the select menu
*/
values: SelectMenuInteractionValues;
constructor(data: DataWithClient<APIMessageSelectMenuInteractionData>, guild?: Guild | null);
}
export declare class ComponentInteraction extends ReplyableInteraction {
/**
* The type of the component
*/
componentType: ComponentType;
/**
* The custom_id of the component
*/
customId: string;
/**
* The selected language of the invoking user
*/
locale: string;
/**
* The guild's preferred locale, if invoked in a guild
*/
guildLocale: string | null;
/**
* For components, the message they were attached to
*/
message: Message;
/**
* The component data payload
*/
data: SelectMenuInteractionData | null;
rawData: APIMessageComponentInteraction;
constructor(data: DataWithClient<APIMessageComponentInteraction>, httpResponse?: InteractionResponse);
deferUpdate(): Promise<void>;
editParent(content: MessagePostData): Promise<void>;
toJSON(): {
readonly createdAt: number;
id: string;
rawData: APIMessageComponentInteraction;
locale: string;
type: number;
channel: Channel | (Partial<APIChannel> & Pick<APIChannel, "id" | "type">);
channelId: string;
version: number;
token: string;
message: Message;
applicationId: string;
acknowledged: boolean;
guildLocale: string | null;
componentType: number;
customId: string;
};
}
export declare class ModalSubmitInteraction extends ReplyableInteraction {
/**
* The selected language of the invoking user
*/
locale: string;
/**
* The guild's preferred locale, if invoked in a guild
*/
guildLocale: string | null;
/**
* For components, the message they were attached to
*/
message: Message | null;
/**
* A developer-defined identifier for the component, max 100 characters
*/
customId: string;
/**
* A list of child components
*/
components: ModalSubmitActionRowComponent[];
constructor(data: DataWithClient<APIModalSubmitInteraction>, httpResponse?: InteractionResponse);
deferUpdate(): Promise<void>;
editParent(data: MessagePostData): Promise<void>;
toJSON(): {
readonly createdAt: number;
id: string;
rawData: APIInteraction;
locale: string;
type: number;
channel: Channel | (Partial<APIChannel> & Pick<APIChannel, "id" | "type">);
channelId: string;
version: number;
token: string;
message: Message | null;
applicationId: string;
acknowledged: boolean;
guildLocale: string | null;
};
}
export declare class CommandInteractionOptions {
#private;
_client: AnyClient;
guild?: Guild | undefined;
subCommand?: string;
subCommandGroup?: string;
constructor(options: APIApplicationCommandInteractionDataOption[], resolved: APIInteractionDataResolved, _client: AnyClient, guild?: Guild | undefined);
/**
* Get a option
* @param name The name of option
* @returns
*/
get(name: string): import("discord-api-types/v10").APIApplicationCommandInteractionDataStringOption | import("discord-api-types/v10").APIApplicationCommandInteractionDataIntegerOption | import("discord-api-types/v10").APIApplicationCommandInteractionDataBooleanOption | import("discord-api-types/v10").APIApplicationCommandInteractionDataNumberOption | {
value: import("discord-api-types/v10").APIAttachment | null;
name: string;
type: ApplicationCommandOptionType.Attachment;
} | {
value: User | null;
name: string;
type: ApplicationCommandOptionType.User;
} | {
value: Channel | import("discord-api-types/v10").APIInteractionDataResolvedChannel | null;
name: string;
type: ApplicationCommandOptionType.Channel;
} | {
value: Role | null;
name: string;
type: ApplicationCommandOptionType.Role;
} | {
value: User | Role | Member | null;
name: string;
type: ApplicationCommandOptionType.Mentionable;
} | undefined;
/**
* Get a string option value
* @param name Option name
* @returns
*/
string(name: string): string | null;
/**
* Get a number option value
* @param name Option name
* @returns
*/
number(name: string): number | null;
/**
* Get a integer option value
* @param name Option name
* @returns
*/
integer(name: string): number | null;
/**
* Get a boolean option value
* @param name Option name
* @returns
*/
boolean(name: string): boolean | null;
/**
* Get a attachment option value
* @param name Option name
* @returns
*/
attachment(name: string): import("discord-api-types/v10").APIAttachment | null;
/**
* Get a user option value
* @param name Option name
* @returns
*/
user(name: string): User | null;
/**
* Get a role option value
* @param name Option name
* @returns
*/
role(name: string): Role | null;
/**
* Get a channel option value
* @param name Option name
* @returns
*/
channel(name: string): Channel | import("discord-api-types/v10").APIInteractionDataResolvedChannel | null;
/**
* Get a mentionable (user, member, role, channel) option value
* @param name Option name
* @returns
*/
mentionable(name: string): User | Role | Member | null;
toArray(): APIApplicationCommandInteractionDataBasicOption[];
}
export declare class AutoCompleteInteractionDataOptions extends CommandInteractionOptions {
/**
* Gets the focused option
* @returns
*/
focusedOption(): APIApplicationCommandInteractionDataBasicOption;
}
export declare class ChatInputApplicationCommandInteractionData extends Base {
/**
* The type of the invoked command
*/
type: ApplicationCommandType.ChatInput;
/**
* The name of the invoked command
*/
name: string;
/**
* The guild ID of the invoked command
*/
guildId?: string;
/**
* The options of the invoked command
*/
options: CommandInteractionOptions | null;
constructor(data: DataWithClient<APIChatInputApplicationCommandInteractionData>, guild?: Guild);
}
export declare class MessageApplicationCommandInteractionData extends Base {
guild?: Guild | undefined;
/**
* The message that the interaction was executed
*/
message: Message;
/**
* Id of the message targeted
*/
targetId: string;
/**
* The type of the invoked command
*/
type: ApplicationCommandType.Message;
/**
* The name of the invoked command
*/
name: string;
constructor(data: DataWithClient<APIMessageApplicationCommandInteractionData>, guild?: Guild | undefined);
}
export declare class UserApplicationCommandInteractionData extends Base {
/**
* User target
*/
target: User | APIUser;
/**
* The name of the invoked command
*/
name: string;
/**
* Id of the user targeted
*/
targetId: string;
/**
* Guild member target
*/
targetMember?: APIInteractionDataResolvedGuildMember | Member;
/**
* The type of the invoked command
*/
type: ApplicationCommandType.User;
constructor(data: DataWithClient<APIUserApplicationCommandInteractionData>, guild?: Guild);
}
export declare class AutoCompleteInteractionData extends Base {
/**
* The name of the invoked command
*/
name: string;
/**
* The type of the invoked command
*/
type: ApplicationCommandType;
/**
* The options of the invoked command
*/
options: AutoCompleteInteractionDataOptions | null;
constructor(data: DataWithClient<APIChatInputApplicationCommandInteractionData>, guild?: Guild);
}
type AnyDataType = ChatInputApplicationCommandInteractionData | UserApplicationCommandInteractionData | MessageApplicationCommandInteractionData;
export declare class CommandInteraction<DataType extends AnyDataType = AnyDataType> extends ReplyableInteraction {
/**
* The guild's preferred locale, if invoked in a guild
*/
guildLocale?: string;
/**
* The command data payload
*/
data: DataType;
/**
* The name of the invoked command
*/
commandName: string;
/**
* The selected language of the invoking user
*/
locale: string;
/**
* For components, the message they were attached to
*/
message: Message | null;
rawData: APIApplicationCommandInteraction;
constructor(data: DataWithClient<APIApplicationCommandInteraction>, httpResponse?: InteractionResponse);
/**
* Create a modal
*/
createModal(data: APIModalInteractionResponseCallbackData): Promise<void>;
isMessageCommand(): this is CommandInteraction<MessageApplicationCommandInteractionData>;
isUserCommand(): this is CommandInteraction<UserApplicationCommandInteractionData>;
isChatInputCommand(): this is CommandInteraction<ChatInputApplicationCommandInteractionData>;
toJSON(): any;
}
export declare class AutocompleteInteraction extends Interaction {
_http?: InteractionResponse;
/**
* This interaction is received for webserver
*/
isHTTP: boolean;
/**
* The interaction is acknowledged
*/
acknowledged: boolean;
/**
* The command data payload
*/
data: AutoCompleteInteractionData;
constructor(data: DataWithClient<APIApplicationCommandAutocompleteInteraction>, httpResponse?: InteractionResponse);
result(choices: APIApplicationCommandOptionChoice[]): Promise<void>;
}
export {};
//# sourceMappingURL=Interaction.d.ts.map