@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); }
@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); }
rEmote = new MessageReaction.ReactionEmote(emote); rEmote = new MessageReaction.ReactionEmote(emojiName, null, getJDA());
return false; if (Emojibet.NEXT_TRACK.equals(emote.getName())) { handleVoteSkip(player, channel, invoker, rank, isAdding); return true; if (Emojibet.STAR.equals(emote.getName())) { OPlaylist playlist = CPlaylist.findBy(CUser.getCachedId(invoker.getIdLong()), 0); if (playlist.id == 0) { } else if (Emojibet.NO_ENTRY.equals(emote.getName())) { handleBanTrack(player, channel, invoker, rank, isAdding); return true;
if (ButtonUtil.isButtonMessage(event.getMessageId())) { for (ButtonGroup.Button button : ButtonUtil.getButtonGroup(event.getMessageId()).getButtons()) { if ((event.getReactionEmote() != null && event.getReactionEmote().isEmote() && event.getReactionEmote().getIdLong() == button.getEmoteId()) || (button.getUnicode() != null && event.getReactionEmote().getName().equals(button.getUnicode()))) { try { if(event.getGuild().getSelfMember().hasPermission(event.getTextChannel(), Permission.MESSAGE_MANAGE)) { event.getChannel().getMessageById(event.getMessageId()).queue(message -> { for (MessageReaction reaction : message.getReactions()) { if (reaction.getReactionEmote().equals(event.getReactionEmote())) { reaction.removeReaction(event.getUser()).queue(); String emote = event.getReactionEmote() != null ? event.getReactionEmote().getName() + "(" + event.getReactionEmote().getId() + ")" : button.getUnicode(); Metrics.buttonsPressed.labels(emote, ButtonUtil.getButtonGroup(event.getMessageId()).getName()).inc(); if (!event.getGuild().getSelfMember().hasPermission(Permission.MESSAGE_MANAGE)) { if (!event.getReactionEmote().getName().equals("\uD83D\uDCCC")) return; // Check if it's a :pushpin: 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) {
.setAction(re -> if(re.getName().equals(LOAD)) m.editMessage(addMsg+"\n"+event.getClient().getSuccess()+" Loaded **"+loadPlaylist(playlist, track)+"** additional tracks!").queue(); else
@SuppressWarnings("ConstantConditions") public void onMessageReactionRemove(MessageReactionRemoveEvent event) { ReactionTransformer transformer = getReactionTransformerFromMessageIdAndCheckPermissions( event.getGuild(), event.getMessageId(), event.getReactionEmote().getEmote().getIdLong() ); if (transformer == null) { return; } Role role = event.getGuild().getRoleById(transformer.getRoleIdFromEmote(event.getReactionEmote().getEmote())); if (role == null) { return; } if (!RoleUtil.hasRole(event.getMember(), role) || !event.getGuild().getSelfMember().canInteract(role)) { return; } DrainReactionRoleQueueTask.queueReactionActionEntity(new DrainReactionRoleQueueTask.ReactionActionEntity( event.getGuild().getIdLong(), event.getMember().getUser().getIdLong(), role.getIdLong(), DrainReactionRoleQueueTask.ReactionActionType.REMOVE )); }
@SuppressWarnings("ConstantConditions") public void onMessageReactionAdd(MessageReactionAddEvent event) { ReactionTransformer transformer = getReactionTransformerFromMessageIdAndCheckPermissions( event.getGuild(), event.getMessageId(), event.getReactionEmote().getEmote().getIdLong() ); if (transformer == null) { return; } Role role = event.getGuild().getRoleById(transformer.getRoleIdFromEmote(event.getReactionEmote().getEmote())); if (role == null) { return; } if (RoleUtil.hasRole(event.getMember(), role) || !event.getGuild().getSelfMember().canInteract(role)) { return; } DrainReactionRoleQueueTask.queueReactionActionEntity(new DrainReactionRoleQueueTask.ReactionActionEntity( event.getGuild().getIdLong(), event.getMember().getUser().getIdLong(), role.getIdLong(), DrainReactionRoleQueueTask.ReactionActionType.ADD )); }
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; }
/** * 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); } }
private boolean isValidMessageReactionEvent(GenericMessageReactionEvent event) { return !event.getUser().isBot() && event.getGuild() != null && event.getReactionEmote().getEmote() != 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 boolean equals(Object obj) { if (obj == this) return true; if (!(obj instanceof MessageReaction)) return false; MessageReaction r = (MessageReaction) obj; return r.emote.equals(emote) && r.self == self && r.messageId == messageId; }
@Override public boolean equals(Object obj) { return obj instanceof ReactionEmote && Objects.equals(((ReactionEmote) obj).id, id) && ((ReactionEmote) obj).getName().equals(name); }