@minesa-org/mini-interaction 0.2.7 → 0.2.8
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.
- package/dist/clients/MiniInteraction.js +8 -6
- package/dist/utils/CommandInteractionOptions.js +1 -0
- package/dist/utils/MessageComponentInteraction.d.ts +19 -0
- package/dist/utils/MessageComponentInteraction.js +2 -0
- package/dist/utils/ModalSubmitInteraction.d.ts +7 -0
- package/dist/utils/ModalSubmitInteraction.js +2 -0
- package/package.json +1 -1
|
@@ -1126,14 +1126,15 @@ export class MiniInteraction {
|
|
|
1126
1126
|
const interactionWithHelpers = createMessageComponentInteraction(interaction, {
|
|
1127
1127
|
onAck: (response) => ackResolver?.(response),
|
|
1128
1128
|
sendFollowUp,
|
|
1129
|
+
trackResponse: (id, token, state) => this.trackInteractionState(id, token, state),
|
|
1130
|
+
canRespond: (id) => this.canRespond(id),
|
|
1129
1131
|
});
|
|
1130
1132
|
// Wrap component handler with timeout and acknowledgment
|
|
1131
1133
|
const timeoutWrapper = createTimeoutWrapper(async () => {
|
|
1132
1134
|
const response = await handler(interactionWithHelpers);
|
|
1133
1135
|
const resolvedResponse = response ?? interactionWithHelpers.getResponse();
|
|
1134
|
-
if (
|
|
1135
|
-
|
|
1136
|
-
"Return an APIInteractionResponse to acknowledge the interaction.");
|
|
1136
|
+
if (this.timeoutConfig.enableResponseDebugLogging) {
|
|
1137
|
+
console.log(`[MiniInteraction] Component handler finished: "${customId}"`);
|
|
1137
1138
|
}
|
|
1138
1139
|
return resolvedResponse;
|
|
1139
1140
|
}, this.timeoutConfig.initialResponseTimeout, `Component "${customId}"`, this.timeoutConfig.enableTimeoutWarnings, ackPromise);
|
|
@@ -1191,14 +1192,15 @@ export class MiniInteraction {
|
|
|
1191
1192
|
const interactionWithHelpers = createModalSubmitInteraction(interaction, {
|
|
1192
1193
|
onAck: (response) => ackResolver?.(response),
|
|
1193
1194
|
sendFollowUp,
|
|
1195
|
+
trackResponse: (id, token, state) => this.trackInteractionState(id, token, state),
|
|
1196
|
+
canRespond: (id) => this.canRespond(id),
|
|
1194
1197
|
});
|
|
1195
1198
|
// Wrap modal handler with timeout and acknowledgment
|
|
1196
1199
|
const timeoutWrapper = createTimeoutWrapper(async () => {
|
|
1197
1200
|
const response = await handler(interactionWithHelpers);
|
|
1198
1201
|
const resolvedResponse = response ?? interactionWithHelpers.getResponse();
|
|
1199
|
-
if (
|
|
1200
|
-
|
|
1201
|
-
"Return an APIInteractionResponse to acknowledge the interaction.");
|
|
1202
|
+
if (this.timeoutConfig.enableResponseDebugLogging) {
|
|
1203
|
+
console.log(`[MiniInteraction] Modal handler finished: "${customId}"`);
|
|
1202
1204
|
}
|
|
1203
1205
|
return resolvedResponse;
|
|
1204
1206
|
}, this.timeoutConfig.initialResponseTimeout, `Modal "${customId}"`, this.timeoutConfig.enableTimeoutWarnings, ackPromise);
|
|
@@ -479,6 +479,7 @@ export function createCommandInteraction(interaction, helpers) {
|
|
|
479
479
|
canRespond: helpers?.canRespond,
|
|
480
480
|
trackResponse: helpers?.trackResponse,
|
|
481
481
|
onAck: helpers?.onAck,
|
|
482
|
+
sendFollowUp: helpers?.sendFollowUp,
|
|
482
483
|
};
|
|
483
484
|
return commandInteraction;
|
|
484
485
|
}
|
|
@@ -22,6 +22,8 @@ export type BaseComponentInteractionHelpers = {
|
|
|
22
22
|
trackTiming?: (interactionId: string, operation: string, startTime: number, success: boolean) => void;
|
|
23
23
|
onAck?: (response: APIInteractionResponse) => void;
|
|
24
24
|
sendFollowUp?: (token: string, response: APIInteractionResponse, messageId?: string) => Promise<void>;
|
|
25
|
+
canRespond?: (interactionId: string) => boolean;
|
|
26
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* Button interaction with helper methods.
|
|
@@ -37,6 +39,8 @@ export interface ButtonInteraction extends Omit<APIMessageComponentInteraction,
|
|
|
37
39
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
38
40
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
39
41
|
}) => APIModalInteractionResponse;
|
|
42
|
+
canRespond?: (interactionId: string) => boolean;
|
|
43
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
40
44
|
}
|
|
41
45
|
export declare const ButtonInteraction: {};
|
|
42
46
|
/**
|
|
@@ -54,6 +58,8 @@ export interface StringSelectInteraction extends Omit<APIMessageComponentInterac
|
|
|
54
58
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
55
59
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
56
60
|
}) => APIModalInteractionResponse;
|
|
61
|
+
canRespond?: (interactionId: string) => boolean;
|
|
62
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
57
63
|
}
|
|
58
64
|
export declare const StringSelectInteraction: {};
|
|
59
65
|
/**
|
|
@@ -71,6 +77,8 @@ export interface RoleSelectInteraction extends Omit<APIMessageComponentInteracti
|
|
|
71
77
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
72
78
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
73
79
|
}) => APIModalInteractionResponse;
|
|
80
|
+
canRespond?: (interactionId: string) => boolean;
|
|
81
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
74
82
|
}
|
|
75
83
|
export declare const RoleSelectInteraction: {};
|
|
76
84
|
/**
|
|
@@ -88,6 +96,8 @@ export interface UserSelectInteraction extends Omit<APIMessageComponentInteracti
|
|
|
88
96
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
89
97
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
90
98
|
}) => APIModalInteractionResponse;
|
|
99
|
+
canRespond?: (interactionId: string) => boolean;
|
|
100
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
91
101
|
}
|
|
92
102
|
export declare const UserSelectInteraction: {};
|
|
93
103
|
/**
|
|
@@ -105,6 +115,8 @@ export interface ChannelSelectInteraction extends Omit<APIMessageComponentIntera
|
|
|
105
115
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
106
116
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
107
117
|
}) => APIModalInteractionResponse;
|
|
118
|
+
canRespond?: (interactionId: string) => boolean;
|
|
119
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
108
120
|
}
|
|
109
121
|
export declare const ChannelSelectInteraction: {};
|
|
110
122
|
/**
|
|
@@ -122,6 +134,8 @@ export interface MentionableSelectInteraction extends Omit<APIMessageComponentIn
|
|
|
122
134
|
showModal: (data: APIModalInteractionResponseCallbackData | {
|
|
123
135
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
124
136
|
}) => APIModalInteractionResponse;
|
|
137
|
+
canRespond?: (interactionId: string) => boolean;
|
|
138
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
125
139
|
}
|
|
126
140
|
export declare const MentionableSelectInteraction: {};
|
|
127
141
|
/**
|
|
@@ -144,6 +158,11 @@ export type MessageComponentInteraction = APIMessageComponentInteraction & {
|
|
|
144
158
|
* This is automatically called by reply() and update() if the interaction is deferred.
|
|
145
159
|
*/
|
|
146
160
|
sendFollowUp?: (token: string, response: APIInteractionResponse, messageId?: string) => Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Optional state management helpers.
|
|
163
|
+
*/
|
|
164
|
+
canRespond?: (interactionId: string) => boolean;
|
|
165
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
147
166
|
/**
|
|
148
167
|
* The selected values from a select menu interaction.
|
|
149
168
|
* This property is only present for select menu interactions.
|
|
@@ -203,5 +203,7 @@ export function createMessageComponentInteraction(interaction, helpers) {
|
|
|
203
203
|
getMentionables,
|
|
204
204
|
onAck: helpers?.onAck,
|
|
205
205
|
sendFollowUp: helpers?.sendFollowUp,
|
|
206
|
+
canRespond: helpers?.canRespond,
|
|
207
|
+
trackResponse: helpers?.trackResponse,
|
|
206
208
|
});
|
|
207
209
|
}
|
|
@@ -16,6 +16,11 @@ export type ModalSubmitInteraction = APIModalSubmitInteraction & {
|
|
|
16
16
|
* This is automatically called by reply() if the interaction is deferred.
|
|
17
17
|
*/
|
|
18
18
|
sendFollowUp?: (token: string, response: APIInteractionResponse, messageId?: string) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Optional state management helpers.
|
|
21
|
+
*/
|
|
22
|
+
canRespond?: (interactionId: string) => boolean;
|
|
23
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
19
24
|
};
|
|
20
25
|
export declare const ModalSubmitInteraction: {};
|
|
21
26
|
/**
|
|
@@ -28,4 +33,6 @@ export declare const ModalSubmitInteraction: {};
|
|
|
28
33
|
export declare function createModalSubmitInteraction(interaction: APIModalSubmitInteraction, helpers?: {
|
|
29
34
|
onAck?: (response: APIInteractionResponse) => void;
|
|
30
35
|
sendFollowUp?: (token: string, response: APIInteractionResponse, messageId?: string) => Promise<void>;
|
|
36
|
+
canRespond?: (interactionId: string) => boolean;
|
|
37
|
+
trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
|
|
31
38
|
}): ModalSubmitInteraction;
|
package/package.json
CHANGED