Search in sources :

Example 1 with GuildMemberAddEvent

use of io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent in project DiscLoader by R3alCl0ud.

the class Guild method addMember.

/**
 * Method used internally by DiscLoader to make a new {@link GuildMember} object
 * when a member's data is recieved
 *
 * @param user
 *            The member's {@link IUser} object.
 * @param roles
 *            The member's role's ids.
 * @param deaf
 *            Is the member deafened?
 * @param mute
 *            Is the member muted?
 * @param nick
 *            The member's nickname.
 * @param emitEvent
 *            if a {@code GuildMemberAddEvent} should be fired by the client.
 * @return The {@link GuildMember} that was instantiated.
 */
@Override
public GuildMember addMember(IUser user, String[] roles, boolean deaf, boolean mute, String nick, boolean emitEvent) {
    boolean exists = members.containsKey(user.getID());
    GuildMember member = new GuildMember(this, user, roles, deaf, mute, nick);
    members.put(member.getID(), member);
    if (loader.ready == true && emitEvent && !exists) {
        memberCount++;
        GuildMemberAddEvent event = new GuildMemberAddEvent(member);
        // loader.emit(DLUtil.Events.GUILD_MEMBER_ADD, event);
        loader.emit(event);
    }
    return member;
}
Also used : GuildMemberAddEvent(io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent) IGuildMember(io.discloader.discloader.entity.guild.IGuildMember)

Example 2 with GuildMemberAddEvent

use of io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent in project DiscLoader by R3alCl0ud.

the class Guild method addMember.

/**
 * Method used internally by DiscLoader to make a new {@link GuildMember} object
 * when a member's data is recieved
 *
 * @param data
 *            The member's data
 * @param shouldEmit
 *            if a {@code GuildMemberAddEvent} should be fired by the client
 * @return The {@link GuildMember} that was instantiated.
 */
public IGuildMember addMember(MemberJSON data, boolean shouldEmit) {
    boolean exists = members.containsKey(SnowflakeUtil.parse(data.user.id));
    IGuildMember member = new GuildMember(this, data);
    members.put(member.getID(), member);
    if (!exists && shouldEmit) {
        memberCount++;
        GuildMemberAddEvent event = new GuildMemberAddEvent(member);
        // loader.emit(DLUtil.Events.GUILD_MEMBER_ADD, event);
        loader.emit(event);
    }
    return member;
}
Also used : GuildMemberAddEvent(io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent) IGuildMember(io.discloader.discloader.entity.guild.IGuildMember) IGuildMember(io.discloader.discloader.entity.guild.IGuildMember)

Example 3 with GuildMemberAddEvent

use of io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent in project DiscLoader by R3alCl0ud.

the class Guild method addMember.

@Override
public IGuildMember addMember(IGuildMember member, boolean emit) {
    members.put(member.getID(), member);
    if (emit) {
        memberCount++;
        loader.emit(new GuildMemberAddEvent(member));
    }
    return member;
}
Also used : GuildMemberAddEvent(io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent)

Aggregations

GuildMemberAddEvent (io.discloader.discloader.common.event.guild.member.GuildMemberAddEvent)3 IGuildMember (io.discloader.discloader.entity.guild.IGuildMember)2