Search in sources :

Example 1 with MessageReactionAddEvent

use of io.discloader.discloader.common.event.message.MessageReactionAddEvent 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));
}
Also used : ITextChannel(io.discloader.discloader.entity.channel.ITextChannel) MessageReactionAddEvent(io.discloader.discloader.common.event.message.MessageReactionAddEvent) IMessage(io.discloader.discloader.entity.message.IMessage) IUser(io.discloader.discloader.entity.user.IUser) IReaction(io.discloader.discloader.entity.message.IReaction) ReactionJSON(io.discloader.discloader.network.json.ReactionJSON) Reaction(io.discloader.discloader.core.entity.message.Reaction) IReaction(io.discloader.discloader.entity.message.IReaction)

Aggregations

MessageReactionAddEvent (io.discloader.discloader.common.event.message.MessageReactionAddEvent)1 Reaction (io.discloader.discloader.core.entity.message.Reaction)1 ITextChannel (io.discloader.discloader.entity.channel.ITextChannel)1 IMessage (io.discloader.discloader.entity.message.IMessage)1 IReaction (io.discloader.discloader.entity.message.IReaction)1 IUser (io.discloader.discloader.entity.user.IUser)1 ReactionJSON (io.discloader.discloader.network.json.ReactionJSON)1