Class MessagePollBuilder
java.lang.Object
net.dv8tion.jda.api.utils.messages.MessagePollBuilder
Builder for
MessagePollData
- See Also:
-
Constructor Summary
ConstructorDescriptionMessagePollBuilder
(String title) Create a new builder instanceCreates a new builder, initialized by the providedMessagePoll
instance. -
Method Summary
Modifier and TypeMethodDescriptionAdd an answer to this poll.Add an answer to this poll.build()
Build the poll data.setDuration
(long duration, TimeUnit unit) Change the duration for this poll.setDuration
(Duration duration) Change the duration for this poll.setLayout
(MessagePoll.LayoutType layout) They poll layout.setMultiAnswer
(boolean multiAnswer) Whether this poll allows selecting multiple answers.Change the title for this poll.
-
Constructor Details
-
MessagePollBuilder
Create a new builder instance- Parameters:
title
- The poll title (up toMessagePoll.MAX_QUESTION_TEXT_LENGTH
characters)- Throws:
IllegalArgumentException
- If the title is blank or longer thanMessagePoll.MAX_QUESTION_TEXT_LENGTH
characters
-
MessagePollBuilder
Creates a new builder, initialized by the providedMessagePoll
instance.- Parameters:
poll
- The poll to copy from- Throws:
IllegalArgumentException
- If null is provided
-
-
Method Details
-
setLayout
They poll layout.- Parameters:
layout
- The layout- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If null orUNKNOWN
is provided
-
setTitle
Change the title for this poll.- Parameters:
title
- The poll title (up toMessagePoll.MAX_QUESTION_TEXT_LENGTH
characters)- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If the title is blank or longer thanMessagePoll.MAX_QUESTION_TEXT_LENGTH
characters
-
setDuration
Change the duration for this poll.
Default:1
dayThe poll will automatically expire after this duration.
- Parameters:
duration
- The duration of this poll (in hours resolution)- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If the duration is null, less than 1 hour, or longer than 168L hours (7 days)
-
setDuration
Change the duration for this poll.
Default:1
dayThe poll will automatically expire after this duration.
- Parameters:
duration
- The duration of this poll (in hours resolution)unit
- The time unit for the duration- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If the time unit is null or the duration is not between 1 and 168L hours (7 days) long
-
setMultiAnswer
Whether this poll allows selecting multiple answers.
Default:false
- Parameters:
multiAnswer
- True, if this poll should allow multiple answers- Returns:
- The updated builder
-
addAnswer
Add an answer to this poll.- Parameters:
title
- The answer title- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If the title is null, blank, or longer than 55 characters
-
addAnswer
Add an answer to this poll.- Parameters:
title
- The answer titleemoji
- Optional emoji to show next to the answer text- Returns:
- The updated builder
- Throws:
IllegalArgumentException
- If the title is null, blank, or longer than 55 characters
-
build
Build the poll data.- Returns:
MessagePollData
- Throws:
IllegalStateException
- If no answers have been added to the builder
-