@minesa-org/mini-interaction 0.0.11 → 0.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,6 @@ import type { JSONEncodable } from "./shared.js";
3
3
  /** Shape describing initial text input data accepted by the builder. */
4
4
  export type TextInputBuilderData = {
5
5
  customId?: string;
6
- label?: string;
7
6
  style?: TextInputStyle;
8
7
  minLength?: number;
9
8
  maxLength?: number;
@@ -22,10 +21,6 @@ export declare class TextInputBuilder implements JSONEncodable<APITextInputCompo
22
21
  * Sets the custom identifier for this text input.
23
22
  */
24
23
  setCustomId(customId: string): this;
25
- /**
26
- * Sets the label displayed above the text input.
27
- */
28
- setLabel(label: string): this;
29
24
  /**
30
25
  * Sets the style of the text input (Short or Paragraph).
31
26
  */
@@ -8,7 +8,6 @@ export class TextInputBuilder {
8
8
  constructor(data = {}) {
9
9
  this.data = {
10
10
  customId: data.customId,
11
- label: data.label,
12
11
  style: data.style ?? TextInputStyle.Short,
13
12
  minLength: data.minLength,
14
13
  maxLength: data.maxLength,
@@ -24,13 +23,6 @@ export class TextInputBuilder {
24
23
  this.data.customId = customId;
25
24
  return this;
26
25
  }
27
- /**
28
- * Sets the label displayed above the text input.
29
- */
30
- setLabel(label) {
31
- this.data.label = label;
32
- return this;
33
- }
34
26
  /**
35
27
  * Sets the style of the text input (Short or Paragraph).
36
28
  */
@@ -85,7 +77,6 @@ export class TextInputBuilder {
85
77
  return {
86
78
  type: ComponentType.TextInput,
87
79
  custom_id: this.data.customId,
88
- label: this.data.label,
89
80
  style: this.data.style ?? TextInputStyle.Short,
90
81
  min_length: this.data.minLength,
91
82
  max_length: this.data.maxLength,
@@ -2,7 +2,7 @@ import type { IncomingMessage, ServerResponse } from "node:http";
2
2
  import { APIInteractionResponse, RESTPostAPIChatInputApplicationCommandsJSONBody, RESTPostAPIContextMenuApplicationCommandsJSONBody } from "discord-api-types/v10";
3
3
  import type { MiniInteractionCommand } from "../types/Commands.js";
4
4
  import { RoleConnectionMetadataTypes } from "../types/RoleConnectionMetadataTypes.js";
5
- import { type MessageComponentInteraction } from "../utils/MessageComponentInteraction.js";
5
+ import { type MessageComponentInteraction, type ButtonInteraction, type StringSelectInteraction, type RoleSelectInteraction, type UserSelectInteraction, type ChannelSelectInteraction, type MentionableSelectInteraction } from "../utils/MessageComponentInteraction.js";
6
6
  import { type ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js";
7
7
  /** Configuration parameters for the MiniInteraction client. */
8
8
  export type MiniInteractionOptions = {
@@ -35,12 +35,24 @@ export type MiniInteractionHandlerResult = {
35
35
  error: string;
36
36
  };
37
37
  };
38
- /** Handler signature invoked for Discord message component interactions. */
38
+ /** Handler signature invoked for Discord button interactions. */
39
+ export type MiniInteractionButtonHandler = (interaction: ButtonInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
40
+ /** Handler signature invoked for Discord string select menu interactions. */
41
+ export type MiniInteractionStringSelectHandler = (interaction: StringSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
42
+ /** Handler signature invoked for Discord role select menu interactions. */
43
+ export type MiniInteractionRoleSelectHandler = (interaction: RoleSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
44
+ /** Handler signature invoked for Discord user select menu interactions. */
45
+ export type MiniInteractionUserSelectHandler = (interaction: UserSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
46
+ /** Handler signature invoked for Discord channel select menu interactions. */
47
+ export type MiniInteractionChannelSelectHandler = (interaction: ChannelSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
48
+ /** Handler signature invoked for Discord mentionable select menu interactions. */
49
+ export type MiniInteractionMentionableSelectHandler = (interaction: MentionableSelectInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
50
+ /** Handler signature invoked for Discord message component interactions (generic). */
39
51
  export type MiniInteractionComponentHandler = (interaction: MessageComponentInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
40
52
  /** Handler signature invoked for Discord modal submit interactions. */
41
53
  export type MiniInteractionModalHandler = (interaction: ModalSubmitInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
42
- /** Unified handler signature that accepts both component and modal interactions. */
43
- export type MiniInteractionHandler = MiniInteractionComponentHandler | MiniInteractionModalHandler;
54
+ /** Unified handler signature that accepts any component or modal interaction. */
55
+ export type MiniInteractionHandler = MiniInteractionButtonHandler | MiniInteractionStringSelectHandler | MiniInteractionRoleSelectHandler | MiniInteractionUserSelectHandler | MiniInteractionChannelSelectHandler | MiniInteractionMentionableSelectHandler | MiniInteractionComponentHandler | MiniInteractionModalHandler;
44
56
  /**
45
57
  * Structure describing a component or modal handler mapped to a custom id.
46
58
  * When auto-loading from the components directory:
package/dist/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export { CommandInteractionOptionResolver, createCommandInteraction, } from "./u
8
8
  export type { CommandInteraction, MentionableOption, ResolvedUserOption, } from "./utils/CommandInteractionOptions.js";
9
9
  export type { MiniInteractionFetchHandler, MiniInteractionNodeHandler, MiniInteractionHandlerResult, MiniInteractionRequest, MiniInteractionOptions, } from "./clients/MiniInteraction.js";
10
10
  export type { MiniInteractionCommand, SlashCommandHandler, UserCommandHandler, MessageCommandHandler, CommandHandler, } from "./types/Commands.js";
11
- export type { MiniInteractionComponent, MiniInteractionComponentHandler, MiniInteractionModal, MiniInteractionModalHandler, MiniInteractionHandler, } from "./clients/MiniInteraction.js";
12
- export type { MessageComponentInteraction, ResolvedUserOption as ComponentResolvedUserOption, ResolvedMentionableOption as ComponentResolvedMentionableOption, } from "./utils/MessageComponentInteraction.js";
11
+ export type { MiniInteractionComponent, MiniInteractionButtonHandler, MiniInteractionStringSelectHandler, MiniInteractionRoleSelectHandler, MiniInteractionUserSelectHandler, MiniInteractionChannelSelectHandler, MiniInteractionMentionableSelectHandler, MiniInteractionComponentHandler, MiniInteractionModal, MiniInteractionModalHandler, MiniInteractionHandler, } from "./clients/MiniInteraction.js";
12
+ export type { MessageComponentInteraction, ButtonInteraction, StringSelectInteraction, RoleSelectInteraction, UserSelectInteraction, ChannelSelectInteraction, MentionableSelectInteraction, ResolvedUserOption as ComponentResolvedUserOption, ResolvedMentionableOption as ComponentResolvedMentionableOption, } from "./utils/MessageComponentInteraction.js";
13
13
  export type { ModalSubmitInteraction } from "./utils/ModalSubmitInteraction.js";
14
14
  export { RoleConnectionMetadataTypes } from "./types/RoleConnectionMetadataTypes.js";
15
15
  export { ChannelType } from "./types/ChannelType.js";
@@ -1,4 +1,4 @@
1
- import { type APIInteractionDataResolvedChannel, type APIInteractionDataResolvedGuildMember, type APIInteractionResponse, type APIInteractionResponseChannelMessageWithSource, type APIInteractionResponseDeferredChannelMessageWithSource, type APIInteractionResponseDeferredMessageUpdate, type APIInteractionResponseUpdateMessage, type APIMessageComponentInteraction, type APIModalInteractionResponse, type APIModalInteractionResponseCallbackData, type APIRole, type APIUser } from "discord-api-types/v10";
1
+ import { type APIInteractionDataResolvedChannel, type APIInteractionDataResolvedGuildMember, type APIInteractionResponse, type APIInteractionResponseChannelMessageWithSource, type APIInteractionResponseDeferredChannelMessageWithSource, type APIInteractionResponseDeferredMessageUpdate, type APIInteractionResponseUpdateMessage, type APIMessageComponentInteraction, type APIMessageButtonInteractionData, type APIMessageChannelSelectInteractionData, type APIMessageMentionableSelectInteractionData, type APIMessageRoleSelectInteractionData, type APIMessageStringSelectInteractionData, type APIMessageUserSelectInteractionData, type APIModalInteractionResponse, type APIModalInteractionResponseCallbackData, type APIRole, type APIUser } from "discord-api-types/v10";
2
2
  import { DeferReplyOptions, InteractionMessageData } from "./interactionMessageHelpers.js";
3
3
  /** Resolved user option including optional guild member data. */
4
4
  export type ResolvedUserOption = {
@@ -13,6 +13,66 @@ export type ResolvedMentionableOption = {
13
13
  type: "role";
14
14
  value: APIRole;
15
15
  };
16
+ /**
17
+ * Base helper methods available on all component interactions.
18
+ */
19
+ type BaseComponentInteractionHelpers = {
20
+ getResponse: () => APIInteractionResponse | null;
21
+ reply: (data: InteractionMessageData) => APIInteractionResponseChannelMessageWithSource;
22
+ deferReply: (options?: DeferReplyOptions) => APIInteractionResponseDeferredChannelMessageWithSource;
23
+ update: (data?: InteractionMessageData) => APIInteractionResponseUpdateMessage;
24
+ deferUpdate: () => APIInteractionResponseDeferredMessageUpdate;
25
+ showModal: (data: APIModalInteractionResponseCallbackData | {
26
+ toJSON(): APIModalInteractionResponseCallbackData;
27
+ }) => APIModalInteractionResponse;
28
+ };
29
+ /**
30
+ * Button interaction with helper methods.
31
+ * Buttons don't have values or resolved data.
32
+ */
33
+ export type ButtonInteraction = Omit<APIMessageComponentInteraction, "data"> & {
34
+ data: APIMessageButtonInteractionData;
35
+ } & BaseComponentInteractionHelpers;
36
+ /**
37
+ * String select menu interaction with helper methods.
38
+ */
39
+ export type StringSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
40
+ data: APIMessageStringSelectInteractionData;
41
+ values: string[];
42
+ getStringValues: () => string[];
43
+ } & BaseComponentInteractionHelpers;
44
+ /**
45
+ * Role select menu interaction with helper methods.
46
+ */
47
+ export type RoleSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
48
+ data: APIMessageRoleSelectInteractionData;
49
+ values: string[];
50
+ getRoles: () => APIRole[];
51
+ } & BaseComponentInteractionHelpers;
52
+ /**
53
+ * User select menu interaction with helper methods.
54
+ */
55
+ export type UserSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
56
+ data: APIMessageUserSelectInteractionData;
57
+ values: string[];
58
+ getUsers: () => ResolvedUserOption[];
59
+ } & BaseComponentInteractionHelpers;
60
+ /**
61
+ * Channel select menu interaction with helper methods.
62
+ */
63
+ export type ChannelSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
64
+ data: APIMessageChannelSelectInteractionData;
65
+ values: string[];
66
+ getChannels: () => APIInteractionDataResolvedChannel[];
67
+ } & BaseComponentInteractionHelpers;
68
+ /**
69
+ * Mentionable select menu interaction with helper methods.
70
+ */
71
+ export type MentionableSelectInteraction = Omit<APIMessageComponentInteraction, "data"> & {
72
+ data: APIMessageMentionableSelectInteractionData;
73
+ values: string[];
74
+ getMentionables: () => ResolvedMentionableOption[];
75
+ } & BaseComponentInteractionHelpers;
16
76
  /**
17
77
  * Represents a component interaction augmented with helper response methods.
18
78
  *
@@ -67,3 +127,4 @@ export type MessageComponentInteraction = APIMessageComponentInteraction & {
67
127
  * @returns A helper-augmented interaction object.
68
128
  */
69
129
  export declare function createMessageComponentInteraction(interaction: APIMessageComponentInteraction): MessageComponentInteraction;
130
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "Mini interaction, connecting your app with Discord via HTTP-interaction (Vercel support).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",