Skip to content

Poll

Implementation of discords Poll object as a Luau builder.

https://discord.com/developers/docs/resources/poll#poll-object

Poll.question  :: Media

The question to be displayed in the poll.

Poll.answers  :: Answer}

The array of possible answers for the poll.

Poll.duration  :: number

Duration in hours for the poll. Discord converts this to an expiry timestamp internally.

Poll.allowMultiselect  :: boolean

Whether users can select multiple answers.

Poll.layoutType  :: PollLayoutType

The layout type of the poll display.

Poll : addAnswer ( answer )  -> Poll

Adds an answer to the poll.

Parameters

answer: JSON

Returns

Poll
Poll : setQuestion ( question )  -> Poll

Sets the question for the poll.

Parameters

question: JSON

Returns

Poll
Poll : setDuration ( hours )  -> Poll

Sets the duration of the poll in hours. Must be a positive integer. Discord uses this to calculate the expiry timestamp internally.

Parameters

hours: number

Returns

Poll
Poll : setMultiselect ( multiselect )  -> Poll

Sets whether the poll allows multiple selections.

Parameters

multiselect: boolean

Returns

Poll
Poll : setLayoutType ( layoutType )  -> Poll

Sets the layout type for the poll.

Parameters

layoutType: PollLayoutType

Returns

Poll
Poll : build ( )  -> JSON

Builds and returns the Poll JSON that can be parsed by the Discord API.

Returns

JSON
Poll . new ( resource )  -> Poll

Responsible for creating a new Poll.

Parameters

resource: {
question: mediaBuilder.JSON?,
answers: { answerBuilder.JSON,
}

Returns

Poll