mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-04 01:40:08 +00:00
@@ -85,6 +85,8 @@ export async function sendInteractionResponse(
|
||||
roles: options.data.allowedMentions!.roles?.map((id) => id.toString()),
|
||||
},
|
||||
file: options.data.file,
|
||||
custom_id: options.data.customId,
|
||||
title: options.data.title,
|
||||
components: options.data.components?.map((component) => ({
|
||||
type: component.type,
|
||||
components: component.components.map((subcomponent) => {
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
InteractionDataResolved,
|
||||
MessageComponentTypes,
|
||||
InteractionDataOption,
|
||||
MessageComponents,
|
||||
} from "../types/mod.ts";
|
||||
import { SnakeCasedPropertiesDeep } from "../types/util.ts";
|
||||
import { Collection } from "../util/collection.ts";
|
||||
@@ -41,6 +42,7 @@ export function transformInteraction(bot: Bot, payload: SnakeCasedPropertiesDeep
|
||||
? {
|
||||
componentType: payload.data.component_type,
|
||||
customId: payload.data.custom_id,
|
||||
components: payload.data.components,
|
||||
values: payload.data.values,
|
||||
id: payload.data.id ? bot.transformers.snowflake(payload.data.id) : undefined,
|
||||
name: payload.data.name,
|
||||
@@ -152,6 +154,8 @@ export interface DiscordenoInteraction {
|
||||
componentType?: MessageComponentTypes;
|
||||
/** The custom id provided for this component. */
|
||||
customId?: string;
|
||||
/** The components if its a Modal Submit interaction. */
|
||||
components?: MessageComponents;
|
||||
/** The values chosen by the user. */
|
||||
values?: string[];
|
||||
/** The Id of the invoked command */
|
||||
|
||||
@@ -1,7 +1,32 @@
|
||||
import { FileContent } from "../../discordeno/fileContent.ts";
|
||||
import { Embed } from "../../embeds/embed.ts";
|
||||
import { AllowedMentions } from "../../messages/allowedMentions.ts";
|
||||
import { MessageComponents } from "../../messages/components/messageComponents.ts";
|
||||
import { CreateMessage } from "../../messages/createMessage.ts";
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata */
|
||||
export interface InteractionApplicationCommandCallbackData extends Omit<CreateMessage, "messageReference"> {
|
||||
export interface InteractionApplicationCommandCallbackData {
|
||||
/** The message contents (up to 2000 characters) */
|
||||
content?: string;
|
||||
/** true if this is a TTS message */
|
||||
tts?: boolean;
|
||||
/** Embedded `rich` content (up to 6000 characters) */
|
||||
embeds?: Embed[];
|
||||
/** Allowed mentions for the message */
|
||||
allowedMentions?: Omit<AllowedMentions, "users" | "roles"> & {
|
||||
/** Array of role_ids to mention (Max size of 100) */
|
||||
roles?: bigint[];
|
||||
/** Array of user_ids to mention (Max size of 100) */
|
||||
users?: bigint[];
|
||||
};
|
||||
/** The contents of the file being sent */
|
||||
file?: FileContent | FileContent[];
|
||||
/** The customId you want to use for this modal response. */
|
||||
customId?: string;
|
||||
/** The title you want to use for this modal response. */
|
||||
title?: string;
|
||||
/** The components you would like to have sent in this message */
|
||||
components?: MessageComponents;
|
||||
/** Set to `64` to make your response ephemeral */
|
||||
flags?: number;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Message, User, Role, Channel, MessageComponentTypes } from "../../mod.ts";
|
||||
import { Message, User, Role, Channel, MessageComponentTypes, MessageComponents } from "../../mod.ts";
|
||||
import { InteractionGuildMember } from "../interactionGuildMember.ts";
|
||||
import { InteractionDataOption } from "./applicationCommandInteractionDataOption.ts";
|
||||
|
||||
@@ -7,6 +7,8 @@ export interface InteractionData {
|
||||
componentType?: MessageComponentTypes;
|
||||
/** The custom id provided for this component. */
|
||||
customId?: string;
|
||||
/** The components if its a Modal Submit interaction. */
|
||||
components?: MessageComponents;
|
||||
/** The values chosen by the user. */
|
||||
values?: string[];
|
||||
/** The Id of the invoked command */
|
||||
|
||||
@@ -7,9 +7,11 @@ export enum InteractionResponseTypes {
|
||||
/** ACK an interaction and edit a response later, the user sees a loading state */
|
||||
DeferredChannelMessageWithSource = 5,
|
||||
/** For components, ACK an interaction and edit the original message later; the user does not see a loading state */
|
||||
DeferredUpdateMessage,
|
||||
DeferredUpdateMessage = 6,
|
||||
/** For components, edit the message the component was attached to */
|
||||
UpdateMessage,
|
||||
UpdateMessage = 7,
|
||||
/** For Application Command Options, send an autocomplete result */
|
||||
ApplicationCommandAutocompleteResult,
|
||||
ApplicationCommandAutocompleteResult = 8,
|
||||
/** For Command or Component interactions, send a Modal response */
|
||||
Modal = 9,
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
/** https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype */
|
||||
export enum InteractionTypes {
|
||||
Ping = 1,
|
||||
ApplicationCommand,
|
||||
MessageComponent,
|
||||
ApplicationCommandAutocomplete,
|
||||
ApplicationCommand = 2,
|
||||
MessageComponent = 3,
|
||||
ApplicationCommandAutocomplete = 4,
|
||||
ModalSubmit = 5,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { ButtonComponent } from "./buttonComponent.ts";
|
||||
import { InputTextComponent } from "./inputTextComponent.ts";
|
||||
import { SelectMenuComponent } from "./selectMenu.ts";
|
||||
|
||||
/** https://discord.com/developers/docs/interactions/message-components#actionrow */
|
||||
@@ -7,7 +8,7 @@ export interface ActionRow {
|
||||
type: 1;
|
||||
/** The components in this row */
|
||||
components:
|
||||
| [SelectMenuComponent | ButtonComponent]
|
||||
| [SelectMenuComponent | ButtonComponent | InputTextComponent]
|
||||
| [ButtonComponent, ButtonComponent]
|
||||
| [ButtonComponent, ButtonComponent, ButtonComponent]
|
||||
| [ButtonComponent, ButtonComponent, ButtonComponent, ButtonComponent]
|
||||
|
||||
20
src/types/messages/components/inputTextComponent.ts
Normal file
20
src/types/messages/components/inputTextComponent.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { MessageComponentTypes } from "./messageComponentTypes.ts";
|
||||
import { TextStyles } from "./textStyles.ts";
|
||||
|
||||
// TODO: docs link
|
||||
export interface InputTextComponent {
|
||||
/** InputText Component is of type 3 */
|
||||
type: MessageComponentTypes.InputText;
|
||||
/** The style of the InputText */
|
||||
style: TextStyles;
|
||||
/** The customId of the InputText */
|
||||
customId: string;
|
||||
/** The label of the InputText */
|
||||
label: string;
|
||||
/** The placeholder of the InputText */
|
||||
placeholder?: string;
|
||||
/** The minimum length of the text the user has to provide */
|
||||
minLength?: number;
|
||||
/** The maximum length of the text the user has to provide */
|
||||
maxLength?: number;
|
||||
}
|
||||
@@ -3,7 +3,9 @@ export enum MessageComponentTypes {
|
||||
/** A row of components at the bottom of a message */
|
||||
ActionRow = 1,
|
||||
/** A button! */
|
||||
Button,
|
||||
Button = 2,
|
||||
/** A select menu. */
|
||||
SelectMenu,
|
||||
SelectMenu = 3,
|
||||
/** An Input Text. */
|
||||
InputText = 4,
|
||||
}
|
||||
|
||||
6
src/types/messages/components/textStyles.ts
Normal file
6
src/types/messages/components/textStyles.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export enum TextStyles {
|
||||
/** Intended for short single-line text */
|
||||
Short = 1,
|
||||
/** Intended for much longer inputs */
|
||||
Paragraph = 2,
|
||||
}
|
||||
Reference in New Issue
Block a user