/** * 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(); } }
public GenericMessageReactionEvent(JDA api, long responseNumber, User user, MessageReaction reaction) { super(api, responseNumber, reaction.getMessageIdLong(), reaction.getChannel()); this.issuer = user; this.reaction = reaction; }
/** * Whether this Reaction was used in a {@link net.dv8tion.jda.core.entities.MessageChannel MessageChannel} * of the specified {@link net.dv8tion.jda.core.entities.ChannelType ChannelType}. * * @param type * The ChannelType to compare * * @return True, if this Reaction was used in a MessageChannel from the specified ChannelType */ public boolean isFromType(ChannelType type) { return getChannelType() == type; }
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) { if (reaction.getCount() == 5) { message.pin().queue((aVoid) -> event.getChannel().getHistory().retrievePast(1).complete().get(0) .delete().queue());
@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); }
/** * Creates a new PaginationAction instance * * @param reaction * The target {@link net.dv8tion.jda.core.entities.MessageReaction MessageReaction} */ public ReactionPaginationAction(MessageReaction reaction) { super(reaction.getJDA(), Route.Messages.GET_REACTION_USERS.compile(reaction.getChannel().getId(), reaction.getMessageId(), getCode(reaction)), 1, 100, 100); this.reaction = reaction; }
/** * Removes this Reaction from the Message. * <br>This will remove our own reaction as an overload * of {@link #removeReaction(User)}. * * <p>Possible ErrorResponses include: * <ul> * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_MESSAGE UNKNOWN_MESSAGE} * <br>If the message this reaction was attached to got deleted.</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#UNKNOWN_CHANNEL UNKNOWN_CHANNEL} * <br>If the channel this reaction was used in got deleted.</li> * * <li>{@link net.dv8tion.jda.core.requests.ErrorResponse#MISSING_ACCESS MISSING_ACCESS} * <br>If we were removed from the channel/guild</li> * </ul> * * @return {@link net.dv8tion.jda.core.requests.RestAction RestAction} - Type: Void * Nothing is returned on success */ @CheckReturnValue public RestAction<Void> removeReaction() { return removeReaction(getJDA().getSelfUser()); }
if (!user.equals(getJDA().getSelfUser())) : MiscUtil.encodeUTF8(emote.getName()); Route.CompiledRoute route; if (user.equals(getJDA().getSelfUser())) route = Route.Messages.REMOVE_OWN_REACTION.compile(channel.getId(), getMessageId(), code); else route = Route.Messages.REMOVE_REACTION.compile(channel.getId(), getMessageId(), code, user.getId()); return new RestAction<Void>(getJDA(), route)
/** * The {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} this Reaction was used in * or {@code null} if this is not from type {@link net.dv8tion.jda.core.entities.ChannelType#TEXT ChannelType.TEXT}! * * @return The {@link net.dv8tion.jda.core.entities.TextChannel TextChannel} or {@code null} */ public TextChannel getTextChannel() { return getChannel() instanceof TextChannel ? (TextChannel) getChannel() : null; }
public MessageReaction createMessageReaction(MessageChannel chan, long id, JSONObject obj) { JSONObject emoji = obj.getJSONObject("emoji"); final Long emojiID = emoji.isNull("id") ? null : emoji.getLong("id"); final String name = emoji.optString("name", null); final boolean animated = emoji.optBoolean("animated"); final int count = Helpers.optInt(obj, "count", -1); final boolean me = Helpers.optBoolean(obj, "me"); final MessageReaction.ReactionEmote reactionEmote; if (emojiID != null) { Emote emote = getJDA().getEmoteById(emojiID); // creates fake emoji because no guild has this emoji id if (emote == null) emote = new EmoteImpl(emojiID, getJDA()).setAnimated(animated).setName(name); reactionEmote = new MessageReaction.ReactionEmote(emote); } else { reactionEmote = new MessageReaction.ReactionEmote(name, null, getJDA()); } return new MessageReaction(chan, reactionEmote, id, me, count); }
@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); }
/** * The {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} this Reaction was used in * or {@code null} if this is not from type {@link net.dv8tion.jda.core.entities.ChannelType#PRIVATE ChannelType.PRIVATE}! * * @return The {@link net.dv8tion.jda.core.entities.PrivateChannel PrivateChannel} or {@code null} */ public PrivateChannel getPrivateChannel() { return getChannel() instanceof PrivateChannel ? (PrivateChannel) getChannel() : null; }
MessageReaction reaction = new MessageReaction(channel, rEmote, messageId, user.equals(getJDA().getSelfUser()), -1);
/** * 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(); } }
public GenericGroupMessageReactionEvent(JDA api, long responseNumber, User user, MessageReaction reaction) { super(api, responseNumber, reaction.getMessageIdLong(), (Group) reaction.getChannel()); this.issuer = user; this.reaction = reaction; }
/** * The {@link net.dv8tion.jda.client.entities.Group Group} this Reaction was used in * or {@code null} if this is not from type {@link net.dv8tion.jda.core.entities.ChannelType#GROUP ChannelType.GROUP}! * * @return The {@link net.dv8tion.jda.client.entities.Group Group} or {@code null} */ public Group getGroup() { return getChannel() instanceof Group ? (Group) getChannel() : null; }
private void onAdd(MessageReaction reaction, User user) { IEventManager manager = getJDA().getEventManager(); switch (reaction.getChannelType()) { case TEXT: manager.handle( new GuildMessageReactionAddEvent( getJDA(), responseNumber, user, reaction)); break; case GROUP: manager.handle( new GroupMessageReactionAddEvent( getJDA(), responseNumber, user, reaction)); break; case PRIVATE: manager.handle( new PrivateMessageReactionAddEvent( getJDA(), responseNumber, user, reaction)); } manager.handle( new MessageReactionAddEvent( getJDA(), responseNumber, user, reaction)); }
public MessageReaction.ReactionEmote getReactionEmote() { return reaction.getReactionEmote(); } }
public GenericPrivateMessageReactionEvent(JDA api, long responseNumber, User user, MessageReaction reaction) { super(api, responseNumber, reaction.getMessageIdLong(), (PrivateChannel) reaction.getChannel()); this.issuer = user; this.reaction = reaction; }
private void onRemove(MessageReaction reaction, User user) { IEventManager manager = getJDA().getEventManager(); switch (reaction.getChannelType()) { case TEXT: manager.handle( new GuildMessageReactionRemoveEvent( getJDA(), responseNumber, user, reaction)); break; case GROUP: manager.handle( new GroupMessageReactionRemoveEvent( getJDA(), responseNumber, user, reaction)); break; case PRIVATE: manager.handle( new PrivateMessageReactionRemoveEvent( getJDA(), responseNumber, user, reaction)); } manager.handle( new MessageReactionRemoveEvent( getJDA(), responseNumber, user, reaction)); } }