use of io.discloader.discloader.core.entity.message.Reaction in project DiscLoader by R3alCl0ud.
the class ReactionRemove method handle.
public void handle(SocketPacket packet) {
ReactionJSON data = gson.fromJson(gson.toJson(packet.d), ReactionJSON.class);
IUser user = EntityRegistry.getUserByID(data.user_id);
ITextChannel channel = EntityRegistry.getTextChannelByID(data.channel_id);
if (channel == null)
channel = EntityRegistry.getPrivateChannelByID(data.channel_id);
if (channel == null)
return;
IMessage message = channel.getMessage(data.message_id);
if (message == null || user == null)
return;
IReaction reaction = new Reaction(data, message);
for (IReaction r : message.getReactions()) {
if (r.getEmoji().toString().equals(reaction.toString()))
reaction = r;
}
message.getReactions().remove(reaction);
loader.emit(new MessageReactionRemoveEvent(message, reaction, user));
}
use of io.discloader.discloader.core.entity.message.Reaction in project DiscLoader by R3alCl0ud.
the class ReactionAdd method handle.
public void handle(SocketPacket packet) {
ReactionJSON data = gson.fromJson(gson.toJson(packet.d), ReactionJSON.class);
IUser user = EntityRegistry.getUserByID(data.user_id);
ITextChannel channel = EntityRegistry.getTextChannelByID(data.channel_id);
if (channel == null)
channel = EntityRegistry.getPrivateChannelByID(data.channel_id);
if (channel == null)
return;
IMessage message = channel.getMessage(data.message_id);
if (message == null || user == null)
return;
IReaction reaction = new Reaction(data, message);
message.getReactions().add(reaction);
loader.emit(new MessageReactionAddEvent(message, reaction, user));
}
Aggregations