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

Code before:

    if (data.interaction) {
      /**
       * Partial data of the interaction that this message is a reply to
       * @type {?MessageInteraction}
       */
      this.interaction = {
        id: data.interaction.id,
        type: data.interaction.type,
        commandName: data.interaction.name,
        user: this.client.users._add(data.interaction.user),
      };
    } else {
      this.interaction ??= null;
    }

    if (data.poll) {
      if (this.poll) {
        this.poll._patch({ ...data.poll });
      }

      /**
       * The poll that was sent with the message
       * @type {?Poll}
       */
      this.poll ??= new Poll(this.client, data.poll, this, this.channel);
    } else {
      this.poll ??= null;
    }

    /**
     * A call associated with a message
     * @typedef {Object} MessageCall
     * @property {Readonly<?Date>} endedAt The time the call ended
     * @property {?number} endedTimestamp The timestamp the call ended
     * @property {Snowflake[]} participants The ids of the users that participated in the call
     */

    if (data.call) {
      /**
       * The call associated with the message
       * @type {?MessageCall}
       */
      this.call = {
        endedTimestamp: data.call.ended_timestamp ? Date.parse(data.call.ended_timestamp) : null,
        participants: data.call.participants,
        get endedAt() {
          return this.endedTimestamp && new Date(this.endedTimestamp);
        },
      };
    } else {

Review comment (refactor):
Maybe move this into an `else` block on the `if` above and drop the `??` to avoid evaluating `this.poll` twice in this branch

Code after:
       * @property {User} user The user that invoked the interaction
       * @property {APIAuthorizingIntegrationOwnersMap} authorizingIntegrationOwners
       * Ids for installation context(s) related to an interaction
       * @property {?Snowflake} originalResponseMessageId
       * Id of the original response message. Present only on follow-up messages
       * @property {?Snowflake} interactedMessageId
       * Id of the message that contained interactive component.
       * Present only on messages created from component interactions
       * @property {?MessageInteractionMetadata} triggeringInteractionMetadata
       * Metadata for the interaction that was used to open the modal. Present only on modal submit interactions
       */

      /**
       * Partial data of the interaction that this message is a result of
       * @type {?MessageInteractionMetadata}
       */
      this.interactionMetadata = _transformAPIMessageInteractionMetadata(this.client, data.interaction_metadata);
    } else {
      this.interactionMetadata ??= null;
    }

    if (data.poll) {
      if (this.poll) {
        this.poll._patch(data.poll);
      } else {
        /**
         * The poll that was sent with the message
         * @type {?Poll}
         */
        this.poll = new Poll(this.client, data.poll, this, this.channel);
      }
    } else {
      this.poll ??= null;
    }

    if (data.message_snapshots) {
      /**
       * The message snapshots associated with the message reference
       * @type {Collection<Snowflake, Message>}
       */
      this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
        const channel = this.client.channels.resolve(this.reference.channelId);
        const snapshotData = {
          ...snapshot.message,
          id: this.reference.messageId,
          channel_id: this.reference.channelId,
          guild_id: this.reference.guildId,
        };

        return coll.set(
          this.reference.messageId,