Search in sources :

Example 1 with GuildMemberRemoveJSON

use of io.discloader.discloader.network.json.GuildMemberRemoveJSON in project DiscLoader by R3alCl0ud.

the class GuildBanAdd method handle.

@Override
public void handle(SocketPacket packet) {
    String d = gson.toJson(packet.d);
    GuildMemberRemoveJSON data = this.gson.fromJson(d, GuildMemberRemoveJSON.class);
    IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
    IUser user = EntityRegistry.addUser(data.user);
    guild.removeMember(user);
    GuildBanAddEvent event = new GuildBanAddEvent(guild, user);
    loader.emit(DLUtil.Events.GUILD_BAN_ADD, event);
    loader.emit(event);
}
Also used : GuildMemberRemoveJSON(io.discloader.discloader.network.json.GuildMemberRemoveJSON) GuildBanAddEvent(io.discloader.discloader.common.event.guild.GuildBanAddEvent) IUser(io.discloader.discloader.entity.user.IUser) IGuild(io.discloader.discloader.entity.guild.IGuild)

Example 2 with GuildMemberRemoveJSON

use of io.discloader.discloader.network.json.GuildMemberRemoveJSON in project DiscLoader by R3alCl0ud.

the class GuildMemberRemove method handle.

@Override
public void handle(SocketPacket packet) {
    String d = this.gson.toJson(packet.d);
    GuildMemberRemoveJSON data = this.gson.fromJson(d, GuildMemberRemoveJSON.class);
    IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
    IGuildMember member = guild.getMember(data.user.id);
    if (member == null)
        member = EntityBuilder.getGuildFactory().buildMember(guild, EntityRegistry.addUser(data.user), new String[] {}, false, false, null);
    guild.removeMember(member);
    if (shouldEmit()) {
        GuildMemberRemoveEvent event = new GuildMemberRemoveEvent(member);
        loader.emit(event);
    }
}
Also used : GuildMemberRemoveJSON(io.discloader.discloader.network.json.GuildMemberRemoveJSON) GuildMemberRemoveEvent(io.discloader.discloader.common.event.guild.member.GuildMemberRemoveEvent) IGuildMember(io.discloader.discloader.entity.guild.IGuildMember) IGuild(io.discloader.discloader.entity.guild.IGuild)

Example 3 with GuildMemberRemoveJSON

use of io.discloader.discloader.network.json.GuildMemberRemoveJSON in project DiscLoader by R3alCl0ud.

the class GuildBanRemove method handle.

@Override
public void handle(SocketPacket packet) {
    String d = gson.toJson(packet.d);
    GuildMemberRemoveJSON data = gson.fromJson(d, GuildMemberRemoveJSON.class);
    IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
    IUser user = EntityRegistry.addUser(data.user);
    GuildBanRemoveEvent event = new GuildBanRemoveEvent(guild, user);
    loader.emit(DLUtil.Events.GUILD_BAN_REMOVE, event);
    loader.emit(event);
}
Also used : GuildMemberRemoveJSON(io.discloader.discloader.network.json.GuildMemberRemoveJSON) GuildBanRemoveEvent(io.discloader.discloader.common.event.guild.GuildBanRemoveEvent) IUser(io.discloader.discloader.entity.user.IUser) IGuild(io.discloader.discloader.entity.guild.IGuild)

Aggregations

IGuild (io.discloader.discloader.entity.guild.IGuild)3 GuildMemberRemoveJSON (io.discloader.discloader.network.json.GuildMemberRemoveJSON)3 IUser (io.discloader.discloader.entity.user.IUser)2 GuildBanAddEvent (io.discloader.discloader.common.event.guild.GuildBanAddEvent)1 GuildBanRemoveEvent (io.discloader.discloader.common.event.guild.GuildBanRemoveEvent)1 GuildMemberRemoveEvent (io.discloader.discloader.common.event.guild.member.GuildMemberRemoveEvent)1 IGuildMember (io.discloader.discloader.entity.guild.IGuildMember)1