本文整理汇总了Java中net.dv8tion.jda.core.JDA.getShardInfo方法的典型用法代码示例。如果您正苦于以下问题:Java JDA.getShardInfo方法的具体用法?Java JDA.getShardInfo怎么用?Java JDA.getShardInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.dv8tion.jda.core.JDA
的用法示例。
在下文中一共展示了JDA.getShardInfo方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public static FredBoat getInstance(JDA jda) {
int sId = jda.getShardInfo() == null ? 0 : jda.getShardInfo().getShardId();
for(FredBoat fb : shards) {
if(((FredBoatBot) fb).getShardId() == sId) {
return fb;
}
}
throw new IllegalStateException("Attempted to get instance for JDA shard that is not indexed");
}
示例2: updateRoles
import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public void updateRoles(JDA jda, long delay, TimeUnit unit)
{
final SnowflakeCacheView<Guild> guilds;
if(jda.getShardInfo() != null)
guilds = jda.asBot().getShardManager().getGuildCache();
else
guilds = jda.getGuildCache();
guilds.forEach(guild -> {
for(short rating = 1; rating <= 5; rating++)
{
short r = rating;
Role role = getRatingRole(guild, r);
// There is a role
if(role != null)
{
guild.getMembersWithRoles(role).stream().filter(member -> {
return getUserRating(member.getUser()) != r; // Has a role that doesn't represent their rank
}).forEach(member ->
guild.getController().removeRolesFromMember(member, role).queue(v -> {}, v -> {}));
getMembersByRating(r, guild).stream().filter(member -> {
return !member.getRoles().contains(role); // Doesn't have the proper role
}).forEach(member ->
guild.getController().addRolesToMember(member, role).queue(v -> {}, v -> {}));
}
}
});
EXECUTOR.schedule(() -> updateRoles(jda, delay, unit), delay, unit);
}
示例3: getId
import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public int getId(JDA jda) {
return jda.getShardInfo() == null ? 0 : jda.getShardInfo().getShardId();
}
示例4: getShardBy
import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public MantaroShard getShardBy(JDA jda) {
if (jda.getShardInfo() == null) return shards[0];
return Arrays.stream(shards).filter(shard -> shard.getId() == jda.getShardInfo().getShardId()).findFirst().orElse(null);
}
示例5: logStatusChange
import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
private void logStatusChange(StatusChangeEvent event) {
JDA jda = event.getJDA();
if (jda.getShardInfo() == null) return;
log.info(String.format("`Shard #%d`: Changed from `%s` to `%s`", jda.getShardInfo().getShardId(), event.getOldStatus(), event.getStatus()));
}