/** * The {@link net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote ReactionEmote} * of the reaction, shortcut for {@code getReaction().getReactionEmote()} * * @return The ReactionEmote instance */ public MessageReaction.ReactionEmote getReactionEmote() { return reaction.getReactionEmote(); } }
public MessageReaction.ReactionEmote getReactionEmote() { return reaction.getReactionEmote(); } }
/** * The {@link net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote ReactionEmote} * <br>Shortcut for {@code getReaction().getReactionEmote()} * * @return The message reaction emote */ public MessageReaction.ReactionEmote getReactionEmote() { return reaction.getReactionEmote(); } }
/** * The {@link net.dv8tion.jda.core.entities.MessageReaction.ReactionEmote ReactionEmote} * <br>Shortcut for {@code getReaction().getReactionEmote()} * * @return The reaction emote */ public MessageReaction.ReactionEmote getReactionEmote() { return reaction.getReactionEmote(); } }
@Override public RestAction<Void> addReaction(String unicode) { Checks.notEmpty(unicode, "Provided Unicode"); MessageReaction reaction = reactions.parallelStream() .filter(r -> Objects.equals(r.getReactionEmote().getName(), unicode)) .findFirst().orElse(null); if (reaction != null && reaction.isSelf()) return new RestAction.EmptyRestAction<>(getJDA(), null); return channel.addReactionById(getIdLong(), unicode); }
protected static String getCode(MessageReaction reaction) { MessageReaction.ReactionEmote emote = reaction.getReactionEmote(); return emote.isEmote() ? emote.getName() + ":" + emote.getId() : MiscUtil.encodeUTF8(emote.getName()); }
@Override public RestAction<Void> addReaction(Emote emote) { Checks.notNull(emote, "Emote"); MessageReaction reaction = reactions.parallelStream() .filter(r -> Objects.equals(r.getReactionEmote().getId(), emote.getId())) .findFirst().orElse(null); if (reaction == null) { Checks.check(emote.canInteract(getJDA().getSelfUser(), channel), "Cannot react with the provided emote because it is not available in the current channel."); } else if (reaction.isSelf()) { return new RestAction.EmptyRestAction<>(getJDA(), null); } return channel.addReactionById(getIdLong(), emote); }
/** * Handles the reaction * * @param channel TextChannel of the message * @param messageId id of the message * @param userId id of the user reacting * @param reaction the reaction */ public void handle(TextChannel channel, long messageId, long userId, MessageReaction reaction) { CommandReactionListener<?> listener = reactions.get(channel.getGuild().getIdLong()).get(messageId); if (!listener.isActive() || listener.getExpiresInTimestamp() < System.currentTimeMillis()) { reactions.get(channel.getGuild().getIdLong()).remove(messageId); } else if (listener.hasReaction(reaction.getReactionEmote().getName()) && listener.getUserId() == userId) { reactions.get(channel.getGuild().getIdLong()).get(messageId).updateLastAction(); Message message = channel.getMessageById(messageId).complete(); listener.react(reaction.getReactionEmote().getName(), message); } }
public final boolean executeReaction(User player, MessageChannel channel, MessageReaction reaction, String messageId) { if (!channel.getType().equals(ChannelType.TEXT) || !reactionMessages.containsKey(messageId)) { return false; } if (!isInAGame(player.getId())) { return false; } if (!getGame(player.getId()).isTurnOf(player)) { return false; } final String input = Misc.emoteToNumber(reaction.getReactionEmote().getName()); Message msg = channel.getMessageById(messageId).complete(); if (msg == null) { return false; } execute(player, (TextChannel) channel, input, msg); return true; }
event.getChannel().getMessageById(event.getMessageId()).queue(message -> { for (MessageReaction reaction : message.getReactions()) { if (reaction.getReactionEmote().equals(event.getReactionEmote())) { reaction.removeReaction(event.getUser()).queue(); event.getChannel().getMessageById(event.getMessageId()).queue(message -> { MessageReaction reaction = message.getReactions().stream().filter(r -> r.getReactionEmote().getName() .equals(event.getReactionEmote().getName())).findFirst().orElse(null); if (reaction != null) {