Search in sources :

Example 1 with GuildRoleCreateEvent

use of io.discloader.discloader.common.event.guild.role.GuildRoleCreateEvent 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;
}
Also used : CreateRole(io.discloader.discloader.network.rest.actions.guild.CreateRole) SendableRole(io.discloader.discloader.entity.sendable.SendableRole) IRole(io.discloader.discloader.entity.guild.IRole) IRole(io.discloader.discloader.entity.guild.IRole) GuildRoleCreateEvent(io.discloader.discloader.common.event.guild.role.GuildRoleCreateEvent)

Example 2 with GuildRoleCreateEvent

use of io.discloader.discloader.common.event.guild.role.GuildRoleCreateEvent in project DiscLoader by R3alCl0ud.

the class RoleCreate method handle.

@Override
public void handle(SocketPacket packet) {
    String d = gson.toJson(packet.d);
    GuildRoleJSON data = gson.fromJson(d, GuildRoleJSON.class);
    IGuild guild = EntityRegistry.getGuildByID(data.guild_id);
    IRole role = guild.addRole(gfac.buildRole(guild, data.role));
    GuildRoleCreateEvent event = new GuildRoleCreateEvent(role);
    loader.emit(DLUtil.Events.GUILD_ROLE_CREATE, event);
    loader.emit(event);
}
Also used : IRole(io.discloader.discloader.entity.guild.IRole) IGuild(io.discloader.discloader.entity.guild.IGuild) GuildRoleJSON(io.discloader.discloader.network.json.GuildRoleJSON) GuildRoleCreateEvent(io.discloader.discloader.common.event.guild.role.GuildRoleCreateEvent)

Aggregations

GuildRoleCreateEvent (io.discloader.discloader.common.event.guild.role.GuildRoleCreateEvent)2 IRole (io.discloader.discloader.entity.guild.IRole)2 IGuild (io.discloader.discloader.entity.guild.IGuild)1 SendableRole (io.discloader.discloader.entity.sendable.SendableRole)1 GuildRoleJSON (io.discloader.discloader.network.json.GuildRoleJSON)1 CreateRole (io.discloader.discloader.network.rest.actions.guild.CreateRole)1