class PollBuilder
implements
JSONEncodable<RESTAPIPoll>export declare class PollBuilder implements JSONEncodable<RESTAPIPoll>A builder that creates API-compatible JSON data for polls.
readonlyanswers : readonly PollAnswerBuilder[]
Gets the answers of this poll.
addAnswers(...answers: RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)>) : this
...answers: RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)>
Appends answers to the poll.
Examples:Using an array:Using rest parameters (variadic):
const answers: APIPollMedia[] = ...;
const poll = new PollBuilder()
.addAnswers(answers);const poll = new PollBuilder()
.addAnswers(
{ text: 'Answer 1' },
{ text: 'Answer 2' },
); setAnswers(...answers: RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)>) : this
...answers: RestOrArray<Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder)>
Sets the answers for this poll.
setDuration(duration: number) : this
duration: number
Sets how long this poll will be open for in hours.
setLayoutType(type: PollLayoutType) : this
type: PollLayoutType
Sets the layout type for this poll.
setMultiSelect(multiSelect?: boolean) : this
multiSelect?: boolean
Sets whether multi-select is enabled for this poll.
setQuestion(options: Omit<APIPollMedia, 'emoji'> | PollQuestionBuilder | ((builder: PollQuestionBuilder) => PollQuestionBuilder)) : this
options: Omit<APIPollMedia, 'emoji'> | PollQuestionBuilder | ((builder: PollQuestionBuilder) => PollQuestionBuilder)
Sets the question for this poll.
spliceAnswers(index: numberdeleteCount: number...answers: (Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder))[]) : this
index: number
deleteCount: number
...answers: (Omit<APIPollAnswer, 'answer_id'> | PollAnswerBuilder | ((builder: PollAnswerBuilder) => PollAnswerBuilder))[]
Removes, replaces, or inserts answers for this poll.
Examples:Remove the first answer:Remove the first n answers:Remove the last answer:
poll.spliceAnswers(0, 1);const n = 4;
poll.spliceAnswers(0, n);poll.spliceAnswers(-1, 1); toJSON(validationOverride?: boolean) : RESTAPIPoll
validationOverride?: boolean
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
updateQuestion(updater: (builder: PollQuestionBuilder) => void) : this
updater: (builder: PollQuestionBuilder) => void
Updates the question of this poll.