@minesa-org/mini-interaction 0.2.13 → 0.2.14
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.
|
@@ -1267,7 +1267,7 @@ export class MiniInteraction {
|
|
|
1267
1267
|
canRespond: (id) => this.canRespond(id),
|
|
1268
1268
|
trackResponse: (id, token, state) => this.trackInteractionState(id, token, state),
|
|
1269
1269
|
onAck: (response) => ackResolver?.(response),
|
|
1270
|
-
sendFollowUp
|
|
1270
|
+
sendFollowUp,
|
|
1271
1271
|
});
|
|
1272
1272
|
response = await command.handler(interactionWithHelpers);
|
|
1273
1273
|
resolvedResponse =
|
|
@@ -256,9 +256,14 @@ export function createCommandInteraction(interaction, helpers) {
|
|
|
256
256
|
throw new Error('Interaction cannot respond: already responded or expired');
|
|
257
257
|
}
|
|
258
258
|
const response = createMessageResponse(InteractionResponseType.ChannelMessageWithSource, data);
|
|
259
|
+
if (isDeferred && this.sendFollowUp) {
|
|
260
|
+
this.sendFollowUp(this.token, response, '');
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
this.onAck?.(response);
|
|
264
|
+
}
|
|
259
265
|
this.trackResponse?.(this.id, this.token, 'responded');
|
|
260
266
|
hasResponded = true;
|
|
261
|
-
this.onAck?.(response);
|
|
262
267
|
return response;
|
|
263
268
|
},
|
|
264
269
|
async followUp(data) {
|
|
@@ -281,17 +286,21 @@ export function createCommandInteraction(interaction, helpers) {
|
|
|
281
286
|
if (this.canRespond && !this.canRespond(this.id)) {
|
|
282
287
|
throw new Error('Interaction cannot edit reply: expired');
|
|
283
288
|
}
|
|
284
|
-
const
|
|
285
|
-
if (!
|
|
289
|
+
const normalizedData = normaliseInteractionMessageData(data);
|
|
290
|
+
if (!normalizedData) {
|
|
286
291
|
throw new Error('[MiniInteraction] editReply requires data');
|
|
287
292
|
}
|
|
288
293
|
const response = {
|
|
289
294
|
type: InteractionResponseType.ChannelMessageWithSource,
|
|
290
|
-
data:
|
|
295
|
+
data: normalizedData,
|
|
291
296
|
};
|
|
292
|
-
if (this.sendFollowUp) {
|
|
297
|
+
if (this.sendFollowUp && (isDeferred || hasResponded)) {
|
|
293
298
|
await this.sendFollowUp(this.token, response, '@original');
|
|
294
299
|
}
|
|
300
|
+
else {
|
|
301
|
+
captureResponse(response);
|
|
302
|
+
this.onAck?.(response);
|
|
303
|
+
}
|
|
295
304
|
this.trackResponse?.(this.id, this.token, 'responded');
|
|
296
305
|
hasResponded = true;
|
|
297
306
|
},
|
package/package.json
CHANGED