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

Code before:
      data = options;
    } else {
      data = MessagePayload.create(this, options, {
        messageReference: {
          messageId: this.id,
          channelId: this.channelId,
          guildId: this.guildId,
          type: MessageReferenceType.Default,
          failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
        },
      });
    }
    return this.client.channels.createMessage(this.channelId, data);
  }

  /**
   * Forwards this message.
   * @param {TextChannelResolvable} channel The channel to forward this message to.
   * @returns {Promise<Message>}
   */
  forward(channel) {
    return this.client.channels.createMessage(channel, {
      messageReference: {
        messageId: this.id,
        channelId: this.channelId,
        guildId: this.guildId,
        type: MessageReferenceType.Forward,
      },
    });
  }

  /**
   * Options for starting a thread on a message.
   * @typedef {Object} StartThreadOptions
   * @property {string} name The name of the new thread
   * @property {ThreadAutoArchiveDuration} [autoArchiveDuration=this.channel.defaultAutoArchiveDuration] The amount of
   * time after which the thread should automatically archive in case of no recent activity
   * @property {string} [reason] Reason for creating the thread
   * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
   */

  /**
   * Create a new public thread from this message
   * @see GuildTextThreadManager#create
   * @param {StartThreadOptions} [options] Options for starting a thread on this message
   * @returns {Promise<ThreadChannel>}
   */
  async startThread(options = {}) {
    if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
    if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
      throw new DiscordjsError(ErrorCodes.MessageThreadParent);

Review comment (suggestion):
This is not typed to support `null`, but we'd be passing `null` here if we're forwarding a DM message. Could cause unexpected things in the future.

https://github.com/discordjs/discord.js/blob/19d48f6d6cb8218b896ddf69be313ebe05a96996/packages/discord.js/typings/index.d.ts#L6363

Code after:
      data = options;
    } else {
      data = MessagePayload.create(this, options, {
        messageReference: {
          messageId: this.id,
          channelId: this.channelId,
          guildId: this.guildId ?? undefined,
          type: MessageReferenceType.Default,
          failIfNotExists: options?.failIfNotExists ?? this.client.options.failIfNotExists,
        },
      });
    }
    return this.client.channels.createMessage(this.channelId, data);
  }

  /**
   * Forwards this message.
   * @param {TextChannelResolvable} channel The channel to forward this message to.
   * @returns {Promise<Message>}
   */
  forward(channel) {
    return this.client.channels.createMessage(channel, {
      messageReference: {
        messageId: this.id,
        channelId: this.channelId,
        guildId: this.guildId ?? undefined,
        type: MessageReferenceType.Forward,
      },
    });
  }

  /**
   * Options for starting a thread on a message.
   * @typedef {Object} StartThreadOptions
   * @property {string} name The name of the new thread
   * @property {ThreadAutoArchiveDuration} [autoArchiveDuration=this.channel.defaultAutoArchiveDuration] The amount of
   * time after which the thread should automatically archive in case of no recent activity
   * @property {string} [reason] Reason for creating the thread
   * @property {number} [rateLimitPerUser] The rate limit per user (slowmode) for the thread in seconds
   */

  /**
   * Create a new public thread from this message
   * @see GuildTextThreadManager#create
   * @param {StartThreadOptions} [options] Options for starting a thread on this message
   * @returns {Promise<ThreadChannel>}
   */
  async startThread(options = {}) {
    if (!this.channel) throw new DiscordjsError(ErrorCodes.ChannelNotCached);
    if (![ChannelType.GuildText, ChannelType.GuildAnnouncement].includes(this.channel.type)) {
      throw new DiscordjsError(ErrorCodes.MessageThreadParent);