@minesa-org/mini-interaction 0.2.16 → 0.2.17

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.
@@ -1584,9 +1584,21 @@ function createTimeoutWrapper(handler, timeoutMs, handlerName, enableWarnings =
1584
1584
  reject(new Error(`Handler timeout: ${handlerName} exceeded ${timeoutMs}ms limit`));
1585
1585
  }, timeoutMs);
1586
1586
  });
1587
+ // Create the handler promise and handle its potential background errors
1588
+ const handlerPromise = (async () => {
1589
+ try {
1590
+ return await handler(...args);
1591
+ }
1592
+ catch (error) {
1593
+ // If this error happens AFTER an ACK was already sent (via ackPromise)
1594
+ // or after a timeout, we MUST still log it because nobody else will catch it.
1595
+ console.error(`[MiniInteraction] ${handlerName} background error:`, error);
1596
+ throw error;
1597
+ }
1598
+ })();
1587
1599
  try {
1588
1600
  const promises = [
1589
- Promise.resolve(handler(...args)),
1601
+ handlerPromise,
1590
1602
  timeoutPromise,
1591
1603
  ];
1592
1604
  if (ackPromise) {
@@ -1606,12 +1618,13 @@ function createTimeoutWrapper(handler, timeoutMs, handlerName, enableWarnings =
1606
1618
  if (timeoutId) {
1607
1619
  clearTimeout(timeoutId);
1608
1620
  }
1609
- // Re-throw the error with additional context
1621
+ // Background errors are already logged above
1610
1622
  if (error instanceof Error &&
1611
1623
  error.message.includes("Handler timeout")) {
1612
1624
  throw error;
1613
1625
  }
1614
- console.error(`[MiniInteraction] ${handlerName} failed:`, error);
1626
+ // Only log here if it wasn't a background error (which we already caught)
1627
+ // But since we catch all in handlerPromise, this is mostly for the timeout/race itself.
1615
1628
  throw error;
1616
1629
  }
1617
1630
  };
@@ -48,7 +48,7 @@ export interface CommandInteraction extends Omit<APIChatInputApplicationCommandI
48
48
  reply(data: InteractionMessageData): Promise<APIInteractionResponseChannelMessageWithSource>;
49
49
  edit(data?: InteractionMessageData): APIInteractionResponseUpdateMessage;
50
50
  followUp(data: InteractionMessageData): Promise<void>;
51
- editReply(data?: InteractionMessageData): Promise<void>;
51
+ editReply(data?: InteractionMessageData): Promise<APIInteractionResponseChannelMessageWithSource | APIInteractionResponseUpdateMessage>;
52
52
  deferReply(options?: DeferReplyOptions): APIInteractionResponseDeferredChannelMessageWithSource;
53
53
  showModal(data: APIModalInteractionResponseCallbackData | {
54
54
  toJSON(): APIModalInteractionResponseCallbackData;
@@ -305,6 +305,7 @@ export function createCommandInteraction(interaction, helpers) {
305
305
  }
306
306
  this.trackResponse?.(this.id, this.token, 'responded');
307
307
  hasResponded = true;
308
+ return response;
308
309
  },
309
310
  deferReply(options) {
310
311
  if (this.canRespond && !this.canRespond(this.id)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
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",