Repository: discordjs/discord.js
File: packages/discord.js/src/structures/interfaces/InteractionResponses.js (JavaScript)

Code before:
   * Defers an update to the message to which the component was attached.
   * @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
   * @returns {Promise<Message|InteractionResponse|InteractionCallbackResponse>}
   * @example
   * // Defer updating and reset the component's loading state
   * interaction.deferUpdate()
   *   .then(console.log)
   *   .catch(console.error);
   */
  async deferUpdate(options = {}) {
    if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
    const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
      body: {
        type: InteractionResponseType.DeferredMessageUpdate,
      },
      auth: false,
      query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
    });
    this.deferred = true;

    if (options.withResponse) {
      return new InteractionCallbackResponse(this.client, response);
    } else {
      return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
    }
  }

  /**
   * Updates the original message of the component on which the interaction was received on.
   * @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
   * @returns {Promise<Message|InteractionResponse|InteractionCallbackResponse>}
   * @example
   * // Remove the components from the message
   * interaction.update({
   *   content: "A component interaction was received",
   *   components: []
   * })
   *   .then(console.log)
   *   .catch(console.error);
   */
  async update(options) {
    if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);

    let messagePayload;
    if (options instanceof MessagePayload) messagePayload = options;
    else messagePayload = MessagePayload.create(this, options);

    const { body: data, files } = await messagePayload.resolveBody().resolveFiles();

    const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
      body: {

Review comment (suggestion):
```suggestion

    return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
```

Code after:
   *   .catch(console.error);
   */
  async deferUpdate(options = {}) {
    if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
    const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
      body: {
        type: InteractionResponseType.DeferredMessageUpdate,
      },
      auth: false,
      query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
    });
    this.deferred = true;

    return options.withResponse
      ? new InteractionCallbackResponse(this.client, response)
      : new InteractionResponse(this, this.message?.interaction?.id);
  }

  /**
   * Updates the original message of the component on which the interaction was received on.
   * @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
   * @returns {Promise<InteractionResponse|InteractionCallbackResponse>}
   * @example
   * // Remove the components from the message
   * interaction.update({
   *   content: "A component interaction was received",
   *   components: []
   * })
   *   .then(console.log)
   *   .catch(console.error);
   */
  async update(options) {
    if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);

    let messagePayload;
    if (options instanceof MessagePayload) messagePayload = options;
    else messagePayload = MessagePayload.create(this, options);

    const { body: data, files } = await messagePayload.resolveBody().resolveFiles();

    const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
      body: {
        type: InteractionResponseType.UpdateMessage,
        data,
      },
      files,
      auth: false,
      query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
    });
    this.replied = true;