use of io.discloader.discloader.common.event.message.GroupMessageUpdateEvent in project DiscLoader by R3alCl0ud.
the class MessageUpdate method handle.
@Override
public void handle(SocketPacket packet) {
MessageJSON data = gson.fromJson(gson.toJson(packet.d), MessageJSON.class);
ITextChannel channel = EntityRegistry.getTextChannelByID(data.channel_id);
if (channel == null)
channel = EntityRegistry.getPrivateChannelByID(data.channel_id);
if (channel == null)
return;
IMessage oldMessage = channel.getMessage(data.id), message = EntityBuilder.getChannelFactory().buildMessage(channel, data);
MessageUpdateEvent event = new MessageUpdateEvent(message, oldMessage);
loader.emit(Events.MESSAGE_UPDATE, event);
loader.emit(event);
if (message.getGuild() != null) {
loader.emit(new GuildMessageUpdateEvent(message, oldMessage));
} else if (channel.getType() == ChannelTypes.DM) {
loader.emit(new PrivateMessageUpdateEvent(message, oldMessage));
} else if (channel.getType() == ChannelTypes.GROUP) {
loader.emit(new GroupMessageUpdateEvent(message, oldMessage));
}
}
Aggregations