@minesa-org/mini-interaction 0.2.11 → 0.2.13

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: (token, response, messageId) => this.sendFollowUp(token, response, messageId),
1271
1271
  });
1272
1272
  response = await command.handler(interactionWithHelpers);
1273
1273
  resolvedResponse =
@@ -46,23 +46,23 @@ 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<APIInteractionResponseChannelMessageWithSource>;
50
49
  edit(data?: InteractionMessageData): APIInteractionResponseUpdateMessage;
51
- editReply(data?: InteractionMessageData): Promise<APIInteractionResponseChannelMessageWithSource | APIInteractionResponseUpdateMessage>;
50
+ followUp(data: InteractionMessageData): Promise<void>;
51
+ editReply(data?: InteractionMessageData): Promise<void>;
52
52
  deferReply(options?: DeferReplyOptions): APIInteractionResponseDeferredChannelMessageWithSource;
53
53
  showModal(data: APIModalInteractionResponseCallbackData | {
54
54
  toJSON(): APIModalInteractionResponseCallbackData;
55
55
  }): APIModalInteractionResponse;
56
56
  withTimeoutProtection<T>(operation: () => Promise<T>, deferOptions?: DeferReplyOptions): Promise<T>;
57
57
  canRespond?(interactionId: string): boolean;
58
- trackResponse?(interactionId: string, token: string, state: "responded" | "deferred"): void;
58
+ trackResponse?(interactionId: string, token: string, state: 'responded' | 'deferred'): void;
59
59
  onAck?(response: APIInteractionResponse): void;
60
60
  sendFollowUp?(token: string, response: APIInteractionResponse, messageId?: string): Promise<void>;
61
61
  }
62
62
  export declare const CommandInteraction: {};
63
63
  export declare function createCommandInteraction(interaction: APIChatInputApplicationCommandInteraction, helpers?: {
64
64
  canRespond?: (interactionId: string) => boolean;
65
- trackResponse?: (interactionId: string, token: string, state: "responded" | "deferred") => void;
65
+ trackResponse?: (interactionId: string, token: string, state: 'responded' | 'deferred') => void;
66
66
  logTiming?: (interactionId: string, operation: string, startTime: number, success: boolean) => void;
67
67
  onAck?: (response: APIInteractionResponse) => void;
68
68
  sendFollowUp?: (token: string, response: APIInteractionResponse, messageId?: string) => Promise<void>;
@@ -253,10 +253,10 @@ export function createCommandInteraction(interaction, helpers) {
253
253
  },
254
254
  reply(data) {
255
255
  if (this.canRespond && !this.canRespond(this.id)) {
256
- throw new Error("Interaction cannot respond: already responded or expired");
256
+ throw new Error('Interaction cannot respond: already responded or expired');
257
257
  }
258
258
  const response = createMessageResponse(InteractionResponseType.ChannelMessageWithSource, data);
259
- this.trackResponse?.(this.id, this.token, "responded");
259
+ this.trackResponse?.(this.id, this.token, 'responded');
260
260
  hasResponded = true;
261
261
  this.onAck?.(response);
262
262
  return response;
@@ -264,53 +264,45 @@ export function createCommandInteraction(interaction, helpers) {
264
264
  async followUp(data) {
265
265
  const normalisedData = normaliseInteractionMessageData(data);
266
266
  if (!normalisedData) {
267
- throw new Error("[MiniInteraction] followUp requires data");
267
+ throw new Error('[MiniInteraction] followUp requires data');
268
268
  }
269
269
  const response = {
270
270
  type: InteractionResponseType.ChannelMessageWithSource,
271
271
  data: normalisedData,
272
272
  };
273
273
  if (this.sendFollowUp) {
274
- await this.sendFollowUp(this.token, response, "");
274
+ await this.sendFollowUp(this.token, response, '');
275
275
  }
276
- return response;
277
276
  },
278
277
  edit(data) {
279
278
  return createMessageResponse(InteractionResponseType.UpdateMessage, data);
280
279
  },
281
280
  async editReply(data) {
282
281
  if (this.canRespond && !this.canRespond(this.id)) {
283
- throw new Error("Interaction cannot edit reply: expired");
282
+ throw new Error('Interaction cannot edit reply: expired');
284
283
  }
285
- if (isDeferred) {
286
- const normalisedData = normaliseInteractionMessageData(data);
287
- if (!normalisedData) {
288
- throw new Error("[MiniInteraction] editReply requires data when deferred");
289
- }
290
- const response = {
291
- type: InteractionResponseType.ChannelMessageWithSource,
292
- data: normalisedData,
293
- };
294
- if (this.sendFollowUp) {
295
- await this.sendFollowUp(this.token, response, "@original");
296
- }
297
- this.trackResponse?.(this.id, this.token, "responded");
298
- hasResponded = true;
299
- return response;
284
+ const normalisedData = normaliseInteractionMessageData(data);
285
+ if (!normalisedData) {
286
+ throw new Error('[MiniInteraction] editReply requires data');
300
287
  }
301
- const response = createMessageResponse(InteractionResponseType.ChannelMessageWithSource, data);
302
- this.trackResponse?.(this.id, this.token, "responded");
288
+ const response = {
289
+ type: InteractionResponseType.ChannelMessageWithSource,
290
+ data: normalisedData,
291
+ };
292
+ if (this.sendFollowUp) {
293
+ await this.sendFollowUp(this.token, response, '@original');
294
+ }
295
+ this.trackResponse?.(this.id, this.token, 'responded');
303
296
  hasResponded = true;
304
- return response;
305
297
  },
306
298
  deferReply(options) {
307
299
  if (this.canRespond && !this.canRespond(this.id)) {
308
- throw new Error("Interaction cannot defer: already responded or expired");
300
+ throw new Error('Interaction cannot defer: already responded or expired');
309
301
  }
310
302
  const response = createDeferredResponse(options?.flags !== undefined
311
303
  ? { flags: options.flags }
312
304
  : undefined);
313
- this.trackResponse?.(this.id, this.token, "deferred");
305
+ this.trackResponse?.(this.id, this.token, 'deferred');
314
306
  isDeferred = true;
315
307
  this.onAck?.(response);
316
308
  return response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minesa-org/mini-interaction",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
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",