@lilybird/transformers
Version:
Event transformers and more for lilybird
160 lines • 8.93 kB
TypeScript
import { GuildMember } from "./guild-member.js";
import { Message } from "./message.js";
import { User } from "./user.js";
import { ApplicationCommandType, InteractionType, ComponentType } from "lilybird";
import type { PartialChannel } from "./channel.js";
import type { Application as LilyApplication, Interaction as LilyInteraction, InteractionContextType, Message as LilyMessage, ResolvedDataStructure, LilybirdAttachment, ApplicationCommand, Webhook, Locale, Client } from "lilybird";
export declare function interactionFactory(client: Client, interaction: LilyInteraction.Structure): Interaction;
export type InteractionData = ApplicationCommandData | AutocompleteData | MessageComponentData | ModalSubmitData | undefined;
export interface AutocompleteData extends ApplicationCommandData<FocusedOption> {
}
export type InteractionReplyOptions = LilyInteraction.MessageCallbackDataStructure & {
componentsV2?: boolean;
ephemeral?: boolean;
suppressEmbeds?: boolean;
};
export interface InteractionShowModalOptions {
title: string;
id: string;
components: Array<LilyMessage.Component.ActionRowStructure>;
}
export interface InteractionEditOptions extends Webhook.EditWebhookJSONParams {
files?: Array<LilybirdAttachment>;
}
export declare class Interaction<T extends InteractionData = InteractionData, M extends undefined | Message = undefined | Message> {
#private;
readonly client: Client;
readonly id: string;
readonly applicationId: string;
readonly type: InteractionType;
readonly token: string;
readonly version = 1;
readonly appPermissions: string;
readonly locale: Locale | undefined;
readonly entitlements: Array<LilyInteraction.EntitlementStructure>;
readonly authorizingIntegrationOwners: LilyApplication.IntegrationTypeMap;
readonly context: InteractionContextType | undefined;
readonly data: T;
readonly message: M;
protected constructor(client: Client, interaction: LilyInteraction.GuildStructure | LilyInteraction.DMStructure, isGuild: boolean, data?: T);
reply(content: string, options?: InteractionReplyOptions): Promise<void>;
reply(options: InteractionReplyOptions): Promise<void>;
deferReply(ephemeral?: boolean): Promise<void>;
deferComponentReply(ephemeral?: boolean): Promise<void>;
updateComponents(content: string, options?: InteractionReplyOptions): Promise<void>;
updateComponents(options: InteractionReplyOptions): Promise<void>;
showChoices(choices: LilyInteraction.AutocompleteCallbackDataStructure["choices"]): Promise<void>;
showModal(title: string, id: string, components: Array<LilyMessage.Component.ActionRowStructure>): Promise<void>;
showModal(options: InteractionShowModalOptions): Promise<void>;
followUp(content: string, options?: InteractionReplyOptions): Promise<Message>;
followUp(options: InteractionReplyOptions): Promise<Message>;
editReply(content: string, options?: InteractionEditOptions): Promise<Message>;
editReply(options: InteractionEditOptions): Promise<Message>;
editFollowUp(messageId: string, content: string, options?: InteractionEditOptions): Promise<Message>;
editFollowUp(messageId: string, options: InteractionEditOptions): Promise<Message>;
deleteReply(): Promise<void>;
deleteFollowUp(messageId: string): Promise<void>;
fetchOriginalReply(): Promise<LilyMessage.Structure>;
isPingInteraction(): this is Interaction<undefined>;
isApplicationCommandInteraction(): this is Interaction<ApplicationCommandData, undefined>;
isAutocompleteInteraction(): this is Interaction<AutocompleteData, undefined>;
isMessageComponentInteraction(): this is Interaction<MessageComponentData, Message>;
isModalSubmitInteraction(): this is Interaction<ModalSubmitData, undefined>;
inGuild(): this is GuildInteraction<T, M>;
inDM(): this is DMInteraction<T, M>;
}
export interface GuildInteraction<T extends InteractionData, M extends undefined | Message = undefined | Message> extends Interaction<T, M> {
isPingInteraction: () => this is GuildInteraction<undefined, undefined>;
isApplicationCommandInteraction: () => this is GuildInteraction<ApplicationCommandData, undefined>;
isAutocompleteInteraction: () => this is GuildInteraction<AutocompleteData, undefined>;
isMessageComponentInteraction: () => this is GuildInteraction<MessageComponentData, Message>;
isModalSubmitInteraction: () => this is GuildInteraction<ModalSubmitData, undefined>;
}
export declare class GuildInteraction<T extends InteractionData, M extends undefined | Message = undefined | Message> extends Interaction<T, M> {
readonly guildId: string;
readonly channel: PartialChannel;
readonly channelId: string;
readonly member: GuildMember;
readonly guildLocale: Locale;
constructor(client: Client, interaction: LilyInteraction.GuildStructure, isDM: boolean, data?: T);
}
export interface DMInteraction<T extends InteractionData, M extends undefined | Message = undefined | Message> extends Interaction<T, M> {
isPingInteraction: () => this is DMInteraction<undefined, undefined>;
isApplicationCommandInteraction: () => this is DMInteraction<ApplicationCommandData, undefined>;
isAutocompleteInteraction: () => this is DMInteraction<AutocompleteData, undefined>;
isMessageComponentInteraction: () => this is DMInteraction<MessageComponentData, Message>;
isModalSubmitInteraction: () => this is DMInteraction<ModalSubmitData, undefined>;
}
export declare class DMInteraction<T extends InteractionData, M extends undefined | Message = undefined | Message> extends Interaction<T, M> {
readonly user: User;
constructor(client: Client, interaction: LilyInteraction.DMStructure, isDM: boolean, data?: T);
}
export interface GuildApplicationCommandData<T extends undefined | FocusedOption> extends ApplicationCommandData<T> {
readonly guildId: string;
}
export interface UIApplicationCommandData<T extends undefined | FocusedOption> extends ApplicationCommandData<T> {
readonly targetId: string;
}
export declare class ApplicationCommandData<T extends undefined | FocusedOption = undefined> {
#private;
readonly id: string;
readonly name: string;
readonly type: ApplicationCommandType;
readonly resolved?: ResolvedDataStructure;
readonly guildId?: string;
readonly targetId?: string;
constructor(data: ApplicationCommand.DataStructure);
isGuildApplicationCommand(): this is GuildApplicationCommandData<T>;
isUIApplicationCommand(): this is UIApplicationCommandData<T>;
isChatInputCommand(): this is {
type: ApplicationCommandType.CHAT_INPUT;
};
isUserCommand(): this is {
type: ApplicationCommandType.USER;
};
isMessageCommand(): this is {
type: ApplicationCommandType.MESSAGE;
};
getFocused<F extends string | number | boolean = string | number | boolean>(): ParseFocusedReturnType<T, F>;
get subCommand(): string | undefined;
get subCommandGroup(): string | undefined;
getString(name: string): string | undefined;
getString(name: string, assert: true): string;
getNumber(name: string): number | undefined;
getNumber(name: string, assert: true): number;
getInteger(name: string): number | undefined;
getInteger(name: string, assert: true): number;
getBoolean(name: string): boolean | undefined;
getBoolean(name: string, assert: true): boolean;
getUser(name: string): string | undefined;
getUser(name: string, assert: true): string;
getChannel(name: string): string | undefined;
getChannel(name: string, assert: true): string;
getRole(name: string): string | undefined;
getRole(name: string, assert: true): string;
getMentionable(name: string): string | undefined;
getMentionable(name: string, assert: true): string;
getAttachment(name: string): string | undefined;
getAttachment(name: string, assert: true): string;
}
export interface FocusedOption<T extends string | number | boolean = string | number | boolean> {
name: string;
value: T;
}
type ParseFocusedReturnType<T extends undefined | FocusedOption, F extends string | number | boolean> = T extends undefined ? undefined : FocusedOption<F>;
export declare class MessageComponentData<T extends Array<string> | undefined = Array<string> | undefined> {
readonly id: string;
readonly type: ComponentType;
readonly values: T;
readonly resolved?: ResolvedDataStructure;
constructor(data: LilyInteraction.MessageComponentDataStructure);
isButton(): this is MessageComponentData;
isSelectMenu(): this is MessageComponentData<Array<string>>;
}
export declare class ModalSubmitData {
readonly id: string;
readonly components: Array<LilyMessage.Component.Structure>;
constructor(data: LilyInteraction.ModalSubmitDataStructure);
}
export {};
//# sourceMappingURL=interaction.d.ts.map