/** * This returns the {@link net.dv8tion.jda.core.entities.Guild Guild} which has the same id as the one provided. * <br>If there is no connected guild with an id that matches the provided one, then this returns {@code null}. * * @param id * The id of the {@link net.dv8tion.jda.core.entities.Guild Guild}. * * @return Possibly-null {@link net.dv8tion.jda.core.entities.Guild Guild} with matching id. */ default Guild getGuildById(long id) { return getGuildCache().getElementById(id); }
/** * This returns the {@link net.dv8tion.jda.core.entities.Guild Guild} which has the same id as the one provided. * <br>If there is no connected guild with an id that matches the provided one, then this returns {@code null}. * * @param id * The id of the {@link net.dv8tion.jda.core.entities.Guild Guild}. * * @throws java.lang.NumberFormatException * If the provided {@code id} cannot be parsed by {@link Long#parseLong(String)} * * @return Possibly-null {@link net.dv8tion.jda.core.entities.Guild Guild} with matching id. */ default Guild getGuildById(String id) { return getGuildCache().getElementById(id); }
/** * An unmodifiable List of all {@link net.dv8tion.jda.core.entities.Guild Guilds} that the logged account is connected to. * <br>If this account is not connected to any {@link net.dv8tion.jda.core.entities.Guild Guilds}, this will return an empty list. * * <p>If the developer is sharding ({@link net.dv8tion.jda.core.JDABuilder#useSharding(int, int)}, then this list * will only contain the {@link net.dv8tion.jda.core.entities.Guild Guilds} that the shard is actually connected to. * Discord determines which guilds a shard is connect to using the following format: * <br>Guild connected if shardId == (guildId {@literal >>} 22) % totalShards; * <br>Source for formula: <a href="https://discordapp.com/developers/docs/topics/gateway#sharding">Discord Documentation</a> * * @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Guild Guilds} that this account is connected to. */ default List<Guild> getGuilds() { return getGuildCache().asList(); }
/** * An unmodifiable list of all {@link net.dv8tion.jda.core.entities.Guild Guilds} that have the same name as the one provided. * <br>If there are no {@link net.dv8tion.jda.core.entities.Guild Guilds} with the provided name, then this returns an empty list. * * @param name * The name of the requested {@link net.dv8tion.jda.core.entities.Guild Guilds}. * @param ignoreCase * Whether to ignore case or not when comparing the provided name to each {@link net.dv8tion.jda.core.entities.Guild#getName()}. * * @return Possibly-empty list of all the {@link net.dv8tion.jda.core.entities.Guild Guilds} that all have the same name as the provided name. */ default List<Guild> getGuildsByName(String name, boolean ignoreCase) { return getGuildCache().getElementsByName(name, ignoreCase); }
public ReadyEvent(JDA api, long responseNumber) { super(api, responseNumber); this.availableGuilds = (int) getJDA().getGuildCache().size(); this.unavailableGuilds = ((JDAImpl) getJDA()).getGuildSetupController().getSetupNodes(GuildSetupController.Status.UNAVAILABLE).size(); }
@Override public void onUserUpdateOnlineStatus(UserUpdateOnlineStatusEvent event) { String shard = Integer.toString(event.getJDA().getShardInfo().getShardId()); int memberCount = event.getJDA().getGuildCache().stream().flatMap(g -> g.getMembers().stream()).collect(Collectors.toList()).size(); members.labels(shard).set(memberCount); }
private final void setGuildCount(JDA jda) { long count = jda.getGuildCache().size(); String shard = Integer.toString(jda.getShardInfo().getShardId()); guilds.labels(shard).set(count); } }
TextChannel defaultChannel = guild.getDefaultChannel(); long guilds = jda.getGuildCache().size(); LOGGER.info("Joined guild: {}", guild.getName());
private boolean hasLoadedGuilds(AvaIre avaire) { if (avaire.getSettings().getShardCount() != -1 && avaire.getShardManager().getShards().size() != avaire.getSettings().getShardCount()) { return false; } for (JDA shard : avaire.getShardManager().getShards()) { if (shard.getGuildCache().isEmpty()) { return false; } } return true; } }