public class PollReactionDecorator extends PermanentReactionDecorator implements Cacheable
Modifier and Type | Field and Description |
---|---|
protected com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> |
onTimeout |
protected com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> |
onVote |
buttons
binding, creationTime, isAlive, listener, listeners, timeout
KEY_ACTION_FUNCTIONAL, KEY_ACTION_SCRIPT, KEY_BINDING_CHANNEL_ID, KEY_BINDING_ID, KEY_CLASS, KEY_CLASS_UNDERLYING, KEY_DELETE_AFTER, KEY_EMOTE, KEY_POLL_VOTE_ACTION, KEY_POLL_VOTES, KEY_TIMEOUT, KEY_TIMEOUT_ACTION
Constructor and Description |
---|
PollReactionDecorator(net.dv8tion.jda.core.entities.Message binding,
long timeout,
com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote,
com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout,
net.dv8tion.jda.core.entities.Emote... emotes)
Constructor that allows only custom server emotes for votes.
|
PollReactionDecorator(net.dv8tion.jda.core.entities.Message binding,
long timeout,
com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote,
com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout,
net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote... votes)
Create a poll decorator using
ReactionEmote for the votes. |
PollReactionDecorator(net.dv8tion.jda.core.entities.Message binding,
long timeout,
com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote,
com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout,
java.lang.String... emotes)
Constructor that allows only unicode emotes for votes.
|
Modifier and Type | Method and Description |
---|---|
java.util.Map<net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote,java.lang.Integer> |
collectVotes()
Request the emotes under the message and count them, minus one for the base reaction.
|
java.util.Map<java.lang.String,java.lang.Integer> |
collectVotesByName()
Same as
collectVotes() but the key will be the name of the emote (or the unicode character). |
protected void |
onTimeout()
Triggered when the decorator times out.
|
protected boolean |
onTrigger(net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent event)
Called when the decorator is triggered.
|
com.electronwill.nightconfig.core.Config |
serialize()
Used to serialize the object into a
Config usable by the config module. |
static PollReactionDecorator |
tryDeserialize(com.electronwill.nightconfig.core.Config serialized,
com.jesus_crie.modularbot.core.ModularBot bot)
Try to convert a
Config into a poll decorator. |
createListener, destroy, destroyButtons, setup
checkTimeout, equals, getBinding, getExpireTime, isAlive, register, register, toString, updateMessage
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
deserializeReactionEmote, getBinding
protected final com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote
protected final com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout
public PollReactionDecorator(@Nonnull net.dv8tion.jda.core.entities.Message binding, long timeout, @Nullable com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote, @Nullable com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout, @Nonnull net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote... votes)
ReactionEmote
for the votes.binding
- The bound message.timeout
- The amount of time in milliseconds before the decorator times out, or 0 for infinite.onVote
- (Optional) The action to perform when a vote is added or removed.onTimeout
- (Optional) The action to perform when the decorator times out.votes
- The emotes that corresponds at the votes that will be counted by the decorator.public PollReactionDecorator(@Nonnull net.dv8tion.jda.core.entities.Message binding, long timeout, @Nullable com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote, @Nullable com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout, @Nonnull java.lang.String... emotes)
binding
- The bound message.timeout
- The amount of time in milliseconds before the decorator times out, or 0 for infinite.onVote
- (Optional) The action to perform when a vote is added or removed.onTimeout
- (Optional) The action to perform when the decorator times out.emotes
- The unicode emotes that will be used for votes.public PollReactionDecorator(@Nonnull net.dv8tion.jda.core.entities.Message binding, long timeout, @Nullable com.jesus_crie.modularbot.core.utils.SerializableBiConsumer<PollReactionDecorator,net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent> onVote, @Nullable com.jesus_crie.modularbot.core.utils.SerializableConsumer<PollReactionDecorator> onTimeout, @Nonnull net.dv8tion.jda.core.entities.Emote... emotes)
binding
- The bound message.timeout
- The amount of time in milliseconds before the decorator times out, or 0 for infinite.onVote
- (Optional) The action to perform when a vote is added or removed.onTimeout
- (Optional) The action to perform when the decorator times out.emotes
- The custom emotes that will be used for votes.protected boolean onTrigger(@Nonnull net.dv8tion.jda.core.events.message.react.GenericMessageReactionEvent event)
ReactionDecorator
onTrigger
in class ReactionDecorator
event
- The event that was thrown.protected void onTimeout()
MessageDecorator
On the other hand, an implementation like ReactionDecorator
will call MessageDecorator.destroy()
on timeout which is an expected behaviour.
onTimeout
in class ReactionDecorator
@Nonnull public java.util.Map<net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote,java.lang.Integer> collectVotes()
@Nonnull public java.util.Map<java.lang.String,java.lang.Integer> collectVotesByName()
collectVotes()
but the key will be the name of the emote (or the unicode character).@Nullable public static PollReactionDecorator tryDeserialize(@Nonnull com.electronwill.nightconfig.core.Config serialized, @Nonnull com.jesus_crie.modularbot.core.ModularBot bot)
Config
into a poll decorator.serialized
- The serialized version of the decorator.bot
- The current instance of the bot.PollReactionDecorator
or null
if it wasn't valid anymore.java.lang.IllegalArgumentException
- If a required field is missing.java.lang.IllegalStateException
- If the binding can't be retrieved (usually it's deleted)@Nonnull public com.electronwill.nightconfig.core.Config serialize()
Cacheable
Config
usable by the config module.