@minesa-org/mini-interaction 0.2.14 → 0.2.15
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.
|
@@ -101,6 +101,10 @@ export class MiniInteraction {
|
|
|
101
101
|
this.trackInteractionState(interactionId, state.token, 'expired');
|
|
102
102
|
return false;
|
|
103
103
|
}
|
|
104
|
+
// Initial response only allowed once if not deferred
|
|
105
|
+
if (state.state === 'responded' && !state.token) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
104
108
|
return true;
|
|
105
109
|
}
|
|
106
110
|
/**
|
|
@@ -1391,7 +1395,10 @@ export class MiniInteraction {
|
|
|
1391
1395
|
}
|
|
1392
1396
|
if (!fetchResponse.ok) {
|
|
1393
1397
|
const errorBody = await fetchResponse.text();
|
|
1394
|
-
console.error(`[MiniInteraction] Failed to send follow-up response: [${fetchResponse.status}] ${errorBody}`);
|
|
1398
|
+
console.error(`[MiniInteraction] Failed to send follow-up response (id=${messageId || 'new'}): [${fetchResponse.status}] ${errorBody}`);
|
|
1399
|
+
if (fetchResponse.status === 404) {
|
|
1400
|
+
console.error("[MiniInteraction] Hint: Interaction token might have expired or the message was deleted.");
|
|
1401
|
+
}
|
|
1395
1402
|
}
|
|
1396
1403
|
}
|
|
1397
1404
|
catch (error) {
|
|
@@ -257,7 +257,7 @@ export function createCommandInteraction(interaction, helpers) {
|
|
|
257
257
|
}
|
|
258
258
|
const response = createMessageResponse(InteractionResponseType.ChannelMessageWithSource, data);
|
|
259
259
|
if (isDeferred && this.sendFollowUp) {
|
|
260
|
-
this.sendFollowUp(this.token, response, '');
|
|
260
|
+
this.sendFollowUp(this.token, response, '@original');
|
|
261
261
|
}
|
|
262
262
|
else {
|
|
263
263
|
this.onAck?.(response);
|
|
@@ -278,6 +278,8 @@ export function createCommandInteraction(interaction, helpers) {
|
|
|
278
278
|
if (this.sendFollowUp) {
|
|
279
279
|
await this.sendFollowUp(this.token, response, '');
|
|
280
280
|
}
|
|
281
|
+
this.trackResponse?.(this.id, this.token, 'responded');
|
|
282
|
+
hasResponded = true;
|
|
281
283
|
},
|
|
282
284
|
edit(data) {
|
|
283
285
|
return createMessageResponse(InteractionResponseType.UpdateMessage, data);
|
|
@@ -32,9 +32,14 @@ function createContextMenuInteractionHelpers(interaction, helpers) {
|
|
|
32
32
|
throw new Error("[MiniInteraction] Interaction cannot respond: already responded or expired");
|
|
33
33
|
}
|
|
34
34
|
const response = createMessageResponse(InteractionResponseType.ChannelMessageWithSource, data);
|
|
35
|
+
if (isDeferred && helpers?.sendFollowUp) {
|
|
36
|
+
helpers.sendFollowUp(interaction.token, response, '@original');
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
helpers?.onAck?.(response);
|
|
40
|
+
}
|
|
35
41
|
hasResponded = true;
|
|
36
42
|
helpers?.trackResponse?.(interaction.id, interaction.token, 'responded');
|
|
37
|
-
helpers?.onAck?.(response);
|
|
38
43
|
return response;
|
|
39
44
|
};
|
|
40
45
|
const followUp = async (data) => {
|
|
@@ -42,6 +47,8 @@ function createContextMenuInteractionHelpers(interaction, helpers) {
|
|
|
42
47
|
if (helpers?.sendFollowUp) {
|
|
43
48
|
await helpers.sendFollowUp(interaction.token, response, '');
|
|
44
49
|
}
|
|
50
|
+
hasResponded = true;
|
|
51
|
+
helpers?.trackResponse?.(interaction.id, interaction.token, 'responded');
|
|
45
52
|
return response;
|
|
46
53
|
};
|
|
47
54
|
const editReply = async (data) => {
|
|
@@ -55,6 +62,8 @@ function createContextMenuInteractionHelpers(interaction, helpers) {
|
|
|
55
62
|
await helpers.sendFollowUp(interaction.token, response, '@original');
|
|
56
63
|
return capturedResponse;
|
|
57
64
|
}
|
|
65
|
+
captureResponse(response);
|
|
66
|
+
helpers?.onAck?.(response);
|
|
58
67
|
hasResponded = true;
|
|
59
68
|
helpers?.trackResponse?.(interaction.id, interaction.token, 'responded');
|
|
60
69
|
return response;
|
|
@@ -36,7 +36,7 @@ export function createMessageComponentInteraction(interaction, helpers) {
|
|
|
36
36
|
data: normalisedData,
|
|
37
37
|
});
|
|
38
38
|
if (isDeferred && helpers?.sendFollowUp) {
|
|
39
|
-
await helpers.sendFollowUp(interaction.token, response, '');
|
|
39
|
+
await helpers.sendFollowUp(interaction.token, response, '@original');
|
|
40
40
|
}
|
|
41
41
|
else {
|
|
42
42
|
helpers?.onAck?.(response);
|
package/package.json
CHANGED