Skip to content

Commit

Permalink
fix: handle more cases
Browse files Browse the repository at this point in the history
  • Loading branch information
almeidx committed Jul 4, 2024
1 parent 46f55e4 commit d51ad49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions packages/discord.js/src/client/actions/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ class GenericAction {
const includePollAnswerPartial = this.client.options.partials.includes(Partials.PollAnswer);
if (message.partial && (!includePollPartial || !includePollAnswerPartial)) return null;

if (!message.poll && includePollPartial && includePollAnswerPartial) {
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);
}

Expand Down
5 changes: 4 additions & 1 deletion packages/discord.js/src/client/actions/MessagePollVoteAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ class MessagePollVoteAddAction extends Action {

const user = this.getUser(data);

answer.voters._add(user);
if (user) {
answer.voters._add(user);
}

answer.voteCount++;

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/structures/Poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Poll extends Base {
* The id of the channel that this poll is in
* @type {Snowflake}
*/
this.channelId = data.channel_id;
this.channelId = data.channel_id ?? channel.id;

/**
* The channel that this poll is in
Expand All @@ -33,7 +33,7 @@ class Poll extends Base {
* The id of the message that started this poll
* @type {Snowflake}
*/
this.messageId = data.message_id;
this.messageId = data.message_id ?? message.id;

/**
* The message that started this poll
Expand Down

0 comments on commit d51ad49

Please sign in to comment.