Search in sources :

Example 1 with GuildSyncException

use of io.discloader.discloader.common.exceptions.GuildSyncException in project DiscLoader by R3alCl0ud.

the class DiscLoader method syncGuilds.

/**
 * Syncs guilds to client if the logged in user is not a bot
 *
 * @param guilds the guilds to sync
 * @throws GuildSyncException
 * @throws AccountTypeException
 */
public void syncGuilds(IGuild... guilds) throws GuildSyncException, AccountTypeException {
    if (user.isBot())
        throw new AccountTypeException("Only user accounts are allowed to sync guilds");
    String[] ids = new String[guilds.length];
    for (int i = 0; i < guilds.length; i++) {
        if (isGuildSyncing(guilds[i]))
            throw new GuildSyncException("Cannot syncing a guild that is currently syncing");
        ids[i] = Long.toUnsignedString(guilds[i].getID());
    }
    Packet packet = new Packet(12, ids);
    gateway.send(packet, true);
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) AccountTypeException(io.discloader.discloader.common.exceptions.AccountTypeException) GuildSyncException(io.discloader.discloader.common.exceptions.GuildSyncException)

Example 2 with GuildSyncException

use of io.discloader.discloader.common.exceptions.GuildSyncException in project DiscLoader by R3alCl0ud.

the class DiscLoader method syncGuilds.

/**
 * Syncs guilds to client if the logged in user is not a bot
 *
 * @param guildIDs the ids of the guilds to sync
 * @throws AccountTypeException
 * @throws GuildSyncException
 */
public void syncGuilds(String... guildIDs) throws AccountTypeException, GuildSyncException {
    if (user.isBot())
        throw new AccountTypeException("Only user accounts are allowed to sync guilds");
    for (String id : guildIDs) {
        if (isGuildSyncing(id))
            throw new GuildSyncException("Cannot syncing a guild that is currently syncing");
    }
    Packet packet = new Packet(12, guildIDs);
    gateway.send(packet, true);
}
Also used : Packet(io.discloader.discloader.entity.sendable.Packet) AccountTypeException(io.discloader.discloader.common.exceptions.AccountTypeException) GuildSyncException(io.discloader.discloader.common.exceptions.GuildSyncException)

Aggregations

AccountTypeException (io.discloader.discloader.common.exceptions.AccountTypeException)2 GuildSyncException (io.discloader.discloader.common.exceptions.GuildSyncException)2 Packet (io.discloader.discloader.entity.sendable.Packet)2