Repository: discordjs/discord.js
File: packages/discord.js/src/client/actions/Action.js (JavaScript)

Code before:

  getMessage(data, channel, cache) {
    const id = data.message_id ?? data.id;
    return (
      data[this.client.actions.injectedMessage] ??
      this.getPayload(
        {
          id,
          channel_id: channel.id,
          guild_id: data.guild_id ?? channel.guild?.id,
        },
        channel.messages,
        id,
        Partials.Message,
        cache,
      )
    );
  }

  getPoll(data, message, channel) {
    const includePollPartial = this.client.options.partials.includes(Partials.Poll);
    const includePollAnswerPartial = this.client.options.partials.includes(Partials.PollAnswer);
    if (message.partial && (!includePollPartial || !includePollAnswerPartial)) return null;

    if (!message.poll && includePollPartial && includePollAnswerPartial) {
      message.poll = new Poll(this.client, { ...data, answers: [] }, message, channel);

      const pollAnswer = new PollAnswer(this.client, data, message.poll);

      message.poll.answers.set(data.answer_id, pollAnswer);
    }

    return message.poll;
  }

  getReaction(data, message, user) {
    const id = data.emoji.id ?? decodeURIComponent(data.emoji.name);
    return this.getPayload(
      {
        emoji: data.emoji,
        count: message.partial ? null : 0,
        me: user?.id === this.client.user.id,
      },
      message.reactions,
      id,
      Partials.Reaction,
    );
  }

  getMember(data, guild) {
    return this.getPayload(data, guild.members, data.user.id, Partials.GuildMember);

Review comment (suggestion):
Not needed anymore
```suggestion
      message.poll = new Poll(this.client, data, message, channel);
```

Code after:

  getMessage(data, channel, cache) {
    const id = data.message_id ?? data.id;
    return (
      data[this.client.actions.injectedMessage] ??
      this.getPayload(
        {
          id,
          channel_id: channel.id,
          guild_id: data.guild_id ?? channel.guild?.id,
        },
        channel.messages,
        id,
        Partials.Message,
        cache,
      )
    );
  }

  getPoll(data, message, channel) {
    const includePollPartial = this.client.options.partials.includes(Partials.Poll);
    const includePollAnswerPartial = this.client.options.partials.includes(Partials.PollAnswer);
    if (message.partial && (!includePollPartial || !includePollAnswerPartial)) return null;

    if (!message.poll && includePollPartial) {
      message.poll = new Poll(this.client, data, message, channel);
    }

    if (message.poll && !message.poll.answers.has(data.answer_id) && includePollAnswerPartial) {
      const pollAnswer = new PollAnswer(this.client, data, message.poll);
      message.poll.answers.set(data.answer_id, pollAnswer);
    }

    return message.poll;
  }

  getReaction(data, message, user) {
    const id = data.emoji.id ?? decodeURIComponent(data.emoji.name);
    return this.getPayload(
      {
        emoji: data.emoji,
        count: message.partial ? null : 0,
        me: user?.id === this.client.user.id,
      },
      message.reactions,
      id,
      Partials.Reaction,
    );
  }

  getMember(data, guild) {