Class MessagePollData
java.lang.Object
net.dv8tion.jda.api.utils.messages.MessagePollData
- All Implemented Interfaces:
SerializableData
A poll that can be attached to a
MessageCreateRequest.
Example
channel.sendMessage("Hello guys! Check my poll:")
.setPoll(
MessagePollData.builder("Which programming language is better?")
.addAnswer("Java", Emoji.fromFormatted("<:java:1006323566314274856>"))
.addAnswer("Kotlin", Emoji.fromFormatted("<:kotlin:295940257797636096>"))
.build())
.queue()
-
Constructor Summary
ConstructorsConstructorDescriptionMessagePollData(MessagePoll.LayoutType layout, MessagePoll.Question question, List<MessagePoll.Answer> answers, Duration duration, boolean isMultiAnswer) -
Method Summary
Modifier and TypeMethodDescriptionstatic MessagePollBuilderCreates a newMessagePollBuilder.static MessagePollDatafrom(MessagePoll poll) Converts aMessagePollto a sendable MessagePollData instance.toData()SerializedDataObjectfor this object.
-
Constructor Details
-
MessagePollData
public MessagePollData(MessagePoll.LayoutType layout, MessagePoll.Question question, List<MessagePoll.Answer> answers, Duration duration, boolean isMultiAnswer)
-
-
Method Details
-
builder
Creates a newMessagePollBuilder.A poll must have at least one answer.
- Parameters:
title- The poll title (up to 300 characters)- Returns:
MessagePollBuilder- Throws:
IllegalArgumentException- If the title is blank or longer than 300 characters
-
from
Converts aMessagePollto a sendable MessagePollData instance.
This does not supportduration, which cannot be derived from an active poll.- Parameters:
poll- The poll to copy- Returns:
- MessagePollData instance
- Throws:
IllegalArgumentException- If null is provided
-
toData
Description copied from interface:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-