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
ConstructorDescriptionMessagePollData
(MessagePoll.LayoutType layout, MessagePoll.Question question, List<MessagePoll.Answer> answers, Duration duration, boolean isMultiAnswer) -
Method Summary
Modifier and TypeMethodDescriptionstatic MessagePollBuilder
Creates a newMessagePollBuilder
.static MessagePollData
from
(MessagePoll poll) Converts aMessagePoll
to a sendable MessagePollData instance.toData()
SerializedDataObject
for 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 aMessagePoll
to 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:SerializableData
SerializedDataObject
for this object.- Specified by:
toData
in interfaceSerializableData
- Returns:
DataObject
-