当前位置: 首页>>代码示例>>Java>>正文


Java JDA.getShardInfo方法代码示例

本文整理汇总了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");
}
 
开发者ID:Frederikam,项目名称:GensokyoBot,代码行数:12,代码来源:FredBoat.java

示例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);
}
 
开发者ID:TheMonitorLizard,项目名称:BalloonBoat,代码行数:33,代码来源:Database.java

示例3: getId

import net.dv8tion.jda.core.JDA; //导入方法依赖的package包/类
public int getId(JDA jda) {
	return jda.getShardInfo() == null ? 0 : jda.getShardInfo().getShardId();
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:4,代码来源:MantaroRPG.java

示例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);
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:5,代码来源:MantaroRPG.java

示例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()));
}
 
开发者ID:Mantaro,项目名称:MantaroRPG,代码行数:6,代码来源:MantaroListener.java


注:本文中的net.dv8tion.jda.core.JDA.getShardInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。