A builder that creates API-compatible JSON data for polls.
Implements
JSONEncodable<RESTAPIPoll>Creates a new poll from API data.
Name | Type | Optional | Description |
---|---|---|---|
data | Partial<RESTAPIPoll> | Yes | The API data to create this poll with |
Appends answers to the poll.
Remarks
This method accepts either an array of answers or a variable number of answer parameters. The maximum amount of answers that can be added is 10.Example
Using an array:Example
Using rest parameters (variadic):Name | Type | Optional | Description |
---|---|---|---|
...answers | RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)> | No | The answers to add |
Clears the duration for this poll.
Clears the layout type for this poll.
Sets the answers for this poll.
Remarks
This method is an alias for spliceAnswers. More specifically, it splices the entire array of answers, replacing them with the provided answers.You can set a maximum of 10 answers.Name | Type | Optional | Description |
---|---|---|---|
...answers | RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)> | No | The answers to set |
Sets how long this poll will be open for in hours.
Remarks
Minimum duration is1
, with maximum duration being 768
(32 days). Default if none specified is 24
(one day).Name | Type | Optional | Description |
---|---|---|---|
duration | number | No | The amount of hours this poll will be open for |
Sets the layout type for this poll.
Remarks
This method is redundant while only one type of poll layout exists (PollLayoutType.Default
) with Discord using that as the layout type if none is specified.Name | Type | Optional | Description |
---|---|---|---|
type | PollLayoutType | No | The type of poll layout to use |
Sets whether multi-select is enabled for this poll.
Name | Type | Optional | Description |
---|---|---|---|
multiSelect | boolean | Yes | Whether to allow multi-select |
Sets the question for this poll.
Name | Type | Optional | Description |
---|---|---|---|
options | Omit<APIPollMedia, 'emoji'> | PollQuestionBuilder | ((builder: PollQuestionBuilder) => PollQuestionBuilder) | No | The data to use for this poll's question |
Removes, replaces, or inserts answers for this poll.
Remarks
This method behaves similarly to Array.prototype.splice(). The maximum amount of answers that can be added is 10.It's useful for modifying and adjusting order of the already-existing answers of a poll.Example
Remove the first answer:Example
Remove the first n answers:Example
Remove the last answer:Name | Type | Optional | Description |
---|---|---|---|
index | number | No | The index to start at |
deleteCount | number | No | The number of answers to remove |
...answers | (Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder))[] | No | The replacing answer objects |
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
Name | Type | Optional | Description |
---|---|---|---|
validationOverride | boolean | Yes | Force validation to run/not run regardless of your global preference |
Updates the question of this poll.
Name | Type | Optional | Description |
---|---|---|---|
updater | (builder: PollQuestionBuilder) => void | No | The function to update the question with |