use of io.discloader.discloader.common.event.guild.member.GuildMemberRoleRemoveEvent in project DiscLoader by R3alCl0ud.
the class GuildMemberUpdate method handle.
@Override
public void handle(SocketPacket packet) {
String d = this.gson.toJson(packet.d);
MemberJSON data = this.gson.fromJson(d, MemberJSON.class);
IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
IGuildMember oldMember = guild.getMember(data.user.id), member = gfac.buildMember(guild, data);
guild.addMember(member);
if (shouldEmit() && oldMember != null) {
GuildMemberUpdateEvent event = new GuildMemberUpdateEvent(member, oldMember);
loader.emit(Events.GUILD_MEMBER_UPDATE, event);
loader.emit(event);
if (!member.getNickname().equals(oldMember.getNickname())) {
loader.emit(new GuildMemberNicknameUpdateEvent(member, oldMember.getNickname()));
}
member.getRoles().forEach(role -> {
if (!oldMember.hasRole(role)) {
loader.emit(new GuildMemberRoleAddEvent(oldMember, member, role));
}
});
oldMember.getRoles().forEach(role -> {
if (!member.hasRole(role)) {
loader.emit(new GuildMemberRoleRemoveEvent(oldMember, member, role));
}
});
// for (member)
}
}
Aggregations