use of io.discloader.discloader.entity.guild.IRole in project DiscLoader by R3alCl0ud.
the class GuildChannel method permissionsOf.
@Override
public IPermission permissionsOf(IGuildMember member) {
long raw = 0;
if (getGuild().isOwner(member))
return new Permission(member, this, 2146958463);
for (IRole role : member.getRoles()) {
if (role != null) {
raw |= role.getPermissions().toLong();
}
}
for (IOverwrite overwrite : overwritesOf(member)) {
raw |= overwrite.getAllowed();
raw &= ~overwrite.getDenied();
}
return new Permission(member, this, raw);
}
use of io.discloader.discloader.entity.guild.IRole in project DiscLoader by R3alCl0ud.
the class Guild method addRole.
@Override
public IRole addRole(RoleJSON guildRole) {
boolean exists = roles.containsKey(SnowflakeUtil.parse(guildRole.id));
IRole role = new Role(this, guildRole);
roles.put(role.getID(), role);
GuildRoleCreateEvent event = new GuildRoleCreateEvent(role);
if (!exists && this.loader.ready) {
loader.emit(event);
}
return role;
}
use of io.discloader.discloader.entity.guild.IRole in project DiscLoader by R3alCl0ud.
the class GuildEmoji method getRoles.
@Override
public Map<Long, IRole> getRoles() {
Map<Long, IRole> roles = new HashMap<>();
for (String roleID : roleIDs) {
IRole role = guild.getRoleByID(roleID);
roles.put(role.getID(), role);
}
return roles;
}
use of io.discloader.discloader.entity.guild.IRole in project DiscLoader by R3alCl0ud.
the class RoleDelete method handle.
@Override
public void handle(SocketPacket packet) {
String d = this.gson.toJson(packet.d);
GuildRoleJSON data = this.gson.fromJson(d, GuildRoleJSON.class);
IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
IRole role = guild.removeRole(data.role_id);
if (role == null)
return;
GuildRoleDeleteEvent event = new GuildRoleDeleteEvent(role);
loader.emit(DLUtil.Events.GUILD_ROLE_DELETE, event);
loader.emit(event);
}
use of io.discloader.discloader.entity.guild.IRole in project DiscLoader by R3alCl0ud.
the class RoleUpdate method handle.
@Override
public void handle(SocketPacket packet) {
String d = this.gson.toJson(packet.d);
Packet data = this.gson.fromJson(d, Packet.class);
IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
IRole oldRole = guild.getRoleByID(data.role.id);
IRole role = guild.addRole(data.role);
GuildRoleUpdateEvent event = new GuildRoleUpdateEvent(role, oldRole);
loader.emit(DLUtil.Events.GUILD_ROLE_UPDATE, event);
loader.emit(event);
}
Aggregations