Search in sources :

Example 6 with ITextChannel

use of io.discloader.discloader.entity.channel.ITextChannel 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)

Example 7 with ITextChannel

use of io.discloader.discloader.entity.channel.ITextChannel in project DiscLoader by R3alCl0ud.

the class TypingStart method handle.

@Override
public void handle(SocketPacket packet) {
    String d = gson.toJson(packet.d);
    TypingStartJSON data = gson.fromJson(d, TypingStartJSON.class);
    ITextChannel channel = EntityRegistry.getTextChannelByID(data.channel_id);
    if (channel == null)
        channel = EntityRegistry.getPrivateChannelByID(data.channel_id);
    if (channel == null)
        return;
    IUser user = EntityRegistry.getUserByID(data.user_id);
    if (user == null || channel.getTyping() == null)
        return;
    channel.getTyping().put(user.getID(), user);
    TypingStartEvent e = new TypingStartEvent(user, channel);
    loader.emit(e);
    loader.emit("TypingStart", e);
}
Also used : ITextChannel(io.discloader.discloader.entity.channel.ITextChannel) TypingStartJSON(io.discloader.discloader.network.json.TypingStartJSON) IUser(io.discloader.discloader.entity.user.IUser) TypingStartEvent(io.discloader.discloader.common.event.channel.TypingStartEvent)

Aggregations

ITextChannel (io.discloader.discloader.entity.channel.ITextChannel)7 IMessage (io.discloader.discloader.entity.message.IMessage)6 IUser (io.discloader.discloader.entity.user.IUser)3 MessageJSON (io.discloader.discloader.network.json.MessageJSON)3 Reaction (io.discloader.discloader.core.entity.message.Reaction)2 IReaction (io.discloader.discloader.entity.message.IReaction)2 ReactionJSON (io.discloader.discloader.network.json.ReactionJSON)2 ChannelUpdateEvent (io.discloader.discloader.common.event.channel.ChannelUpdateEvent)1 GuildChannelUpdateEvent (io.discloader.discloader.common.event.channel.GuildChannelUpdateEvent)1 TypingStartEvent (io.discloader.discloader.common.event.channel.TypingStartEvent)1 GroupMessageUpdateEvent (io.discloader.discloader.common.event.message.GroupMessageUpdateEvent)1 GuildMessageCreateEvent (io.discloader.discloader.common.event.message.GuildMessageCreateEvent)1 GuildMessageDeleteEvent (io.discloader.discloader.common.event.message.GuildMessageDeleteEvent)1 GuildMessageUpdateEvent (io.discloader.discloader.common.event.message.GuildMessageUpdateEvent)1 MessageCreateEvent (io.discloader.discloader.common.event.message.MessageCreateEvent)1 MessageDeleteEvent (io.discloader.discloader.common.event.message.MessageDeleteEvent)1 MessageReactionAddEvent (io.discloader.discloader.common.event.message.MessageReactionAddEvent)1 MessageReactionRemoveEvent (io.discloader.discloader.common.event.message.MessageReactionRemoveEvent)1 MessageUpdateEvent (io.discloader.discloader.common.event.message.MessageUpdateEvent)1 PrivateMessageCreateEvent (io.discloader.discloader.common.event.message.PrivateMessageCreateEvent)1