use of net.dv8tion.jda.api.events.message.react.MessageReactionRemoveEmoteEvent in project JDA by DV8FromTheWorld.
the class MessageReactionClearEmoteHandler method handleInternally.
@Override
protected Long handleInternally(DataObject content) {
long guildId = content.getUnsignedLong("guild_id");
if (getJDA().getGuildSetupController().isLocked(guildId))
return guildId;
Guild guild = getJDA().getGuildById(guildId);
if (guild == null) {
EventCache.LOG.debug("Caching MESSAGE_REACTION_REMOVE_EMOJI event for unknown guild {}", guildId);
getJDA().getEventCache().cache(EventCache.Type.GUILD, guildId, responseNumber, allContent, this::handle);
return null;
}
long channelId = content.getUnsignedLong("channel_id");
// TODO-v5-unified-channel-cache
GuildMessageChannel channel = guild.getTextChannelById(channelId);
if (channel == null)
channel = guild.getNewsChannelById(channelId);
if (channel == null)
channel = guild.getThreadChannelById(channelId);
if (channel == null) {
EventCache.LOG.debug("Caching MESSAGE_REACTION_REMOVE_EMOJI event for unknown channel {}", channelId);
getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
return null;
}
long messageId = content.getUnsignedLong("message_id");
DataObject emoji = content.getObject("emoji");
MessageReaction.ReactionEmote reactionEmote = null;
if (emoji.isNull("id")) {
reactionEmote = MessageReaction.ReactionEmote.fromUnicode(emoji.getString("name"), getJDA());
} else {
long emoteId = emoji.getUnsignedLong("id");
Emote emote = getJDA().getEmoteById(emoteId);
if (emote == null) {
emote = new EmoteImpl(emoteId, getJDA()).setAnimated(emoji.getBoolean("animated")).setName(emoji.getString("name", ""));
}
reactionEmote = MessageReaction.ReactionEmote.fromCustom(emote);
}
MessageReaction reaction = new MessageReaction(channel, reactionEmote, messageId, false, 0);
getJDA().handleEvent(new MessageReactionRemoveEmoteEvent(getJDA(), responseNumber, messageId, channel, reaction));
return null;
}
Aggregations