@minesa-org/mini-interaction 0.2.12 → 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.
@@ -46,8 +46,8 @@ export interface CommandInteraction extends Omit<APIChatInputApplicationCommandI
46
46
  options: CommandInteractionOptionResolver;
47
47
  getResponse(): APIInteractionResponse | null;
48
48
  reply(data: InteractionMessageData): APIInteractionResponseChannelMessageWithSource;
49
- followUp(data: InteractionMessageData): Promise<void>;
50
49
  edit(data?: InteractionMessageData): APIInteractionResponseUpdateMessage;
50
+ followUp(data: InteractionMessageData): Promise<void>;
51
51
  editReply(data?: InteractionMessageData): Promise<void>;
52
52
  deferReply(options?: DeferReplyOptions): APIInteractionResponseDeferredChannelMessageWithSource;
53
53
  showModal(data: APIModalInteractionResponseCallbackData | {
@@ -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 normalisedData = normaliseInteractionMessageData(data);
285
- if (!normalisedData) {
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: normalisedData,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.2.12",
3
+ "version": "0.2.14",
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",