@minesa-org/mini-interaction 0.4.5 → 0.4.6

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.
@@ -203,8 +203,13 @@ export class MiniInteraction {
203
203
  }
204
204
  async runWithResponseLifecycle(interaction, executor) {
205
205
  let ackResponse;
206
+ let initialResponseCommitted = false;
206
207
  const helpers = {
207
- canRespond: (interactionId) => (this.responseStates.get(interactionId) ?? "pending") === "pending",
208
+ // Legacy helper contracts use canRespond for both initial acknowledgements
209
+ // and later editReply/followUp calls. The compat layer does not currently
210
+ // track Discord token expiry, so we only block on real expiry outside of
211
+ // this helper and allow the wrapped interaction methods to complete.
212
+ canRespond: (_interactionId) => true,
208
213
  trackResponse: (interactionId, _token, state) => {
209
214
  this.responseStates.set(interactionId, state);
210
215
  },
@@ -212,6 +217,14 @@ export class MiniInteraction {
212
217
  ackResponse = response;
213
218
  },
214
219
  sendFollowUp: async (token, response, messageId) => {
220
+ // If the initial interaction response has not been sent yet, collapse the
221
+ // deferred/edit flow back into a single immediate response instead of
222
+ // calling the webhook endpoints early.
223
+ if (!initialResponseCommitted) {
224
+ ackResponse = response;
225
+ this.responseStates.set(interaction.id, "responded");
226
+ return;
227
+ }
215
228
  const responseData = "data" in response ? response.data ?? {} : {};
216
229
  if (messageId === "@original") {
217
230
  await this.rest.editOriginal(token, responseData);
@@ -247,6 +260,7 @@ export class MiniInteraction {
247
260
  if (this.options.debug || this.options.timeoutConfig?.enableResponseDebugLogging) {
248
261
  console.debug(`[MiniInteraction] Interaction ${interaction.id} completed with ${result ? "explicit" : "fallback"} response.`);
249
262
  }
263
+ initialResponseCommitted = true;
250
264
  return result ?? ackResponse;
251
265
  }
252
266
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
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",