use of io.discloader.discloader.common.event.message.MessageDeleteEvent in project DiscLoader by R3alCl0ud.
the class MessageDelete method handle.
@Override
public void handle(SocketPacket packet) {
MessageJSON data = this.gson.fromJson(this.gson.toJson(packet.d), MessageJSON.class);
long channelID = SnowflakeUtil.parse(data.channel_id);
ITextChannel channel = EntityRegistry.getTextChannelByID(channelID);
if (channel == null)
channel = EntityRegistry.getPrivateChannelByID(channelID);
if (channel == null)
return;
IMessage message = channel.getMessage(data.id);
if (message == null)
return;
channel.getMessages().remove(message.getID());
MessageDeleteEvent event = new MessageDeleteEvent(message);
loader.emit(Events.MESSAGE_DELETE, event);
loader.emit(event);
if (channel.getType() == ChannelTypes.DM) {
loader.emit(new PrivateMessageDeleteEvent(message));
}
if (message.getGuild() != null) {
loader.emit(new GuildMessageDeleteEvent(message));
}
}
Aggregations