Poll

class Poll

A poll attached to a message, including its choices, vote counts, expiration, and finalization state.

Properties

Property

Type

Description

allowMultiselect

boolean

Indicates whether members can select multiple answers.

answers

{ answerId: number; count: number; meVoted: boolean; text: string; }[]

Array of answer options with their vote counts.

channelId

string | null

ID of the channel containing this poll, or null when the poll is not attached to a message.

expiration

Date | null

When the poll expires, or null if no expiration is set.

layoutType

number

Underlying Discord poll layout type identifier.

messageId

string | null

ID of the message containing this poll, or null when the poll is not attached to a message.

question

{ text: string; }

The question prompt for this poll.

results

{ answerCounts: { count: number; id: number; }[]; isFinalized: boolean; } | null

Aggregated results, or null when Discord omitted them.

Methods

async Poll.fetchVoters(answerId: number, options: { after?: string; limit?: number; }) → Promise<User[]>

Fetch users who voted for one answer.

Poll.getTotalVotes() → number | null

Get the total number of votes cast across all answers.

Returns:

The sum of votes, or null when Discord omitted poll results.

Poll.getVoteCount(answerId: number) → number | null

Get the vote count for a specific answer ID.

Parameters:
  • answerId: The numeric ID of the answer choice.

Returns:

The answer’s vote count, or null when Discord omitted poll results.

Poll.isFinalized() → boolean

Indicates whether the poll results are finalized (no more voting).

Returns:

true if the poll results have been published and voting has ended.