use of net.dv8tion.jda.api.events.message.MessageEmbedEvent in project JDA by DV8FromTheWorld.
the class MessageUpdateHandler method handleMessageEmbed.
private Long handleMessageEmbed(DataObject content) {
EntityBuilder builder = getJDA().getEntityBuilder();
final long messageId = content.getLong("id");
final long channelId = content.getLong("channel_id");
LinkedList<MessageEmbed> embeds = new LinkedList<>();
// TODO-v5-unified-channel-cache
// TODO-v5: handle for threads.
MessageChannel channel = getJDA().getTextChannelsView().get(channelId);
if (channel == null)
channel = getJDA().getNewsChannelById(channelId);
if (channel == null)
channel = getJDA().getPrivateChannelsView().get(channelId);
if (channel == null) {
getJDA().getEventCache().cache(EventCache.Type.CHANNEL, channelId, responseNumber, allContent, this::handle);
EventCache.LOG.debug("Received message update for embeds for a channel/group that JDA does not have cached yet.");
return null;
}
DataArray embedsJson = content.getArray("embeds");
for (int i = 0; i < embedsJson.length(); i++) embeds.add(builder.createMessageEmbed(embedsJson.getObject(i)));
getJDA().handleEvent(new MessageEmbedEvent(getJDA(), responseNumber, messageId, channel, embeds));
return null;
}
Aggregations