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


Java IGuild.getRoleByID方法代码示例

本文整理汇总了Java中sx.blah.discord.handle.obj.IGuild.getRoleByID方法的典型用法代码示例。如果您正苦于以下问题:Java IGuild.getRoleByID方法的具体用法?Java IGuild.getRoleByID怎么用?Java IGuild.getRoleByID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sx.blah.discord.handle.obj.IGuild的用法示例。


在下文中一共展示了IGuild.getRoleByID方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRole

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
public static long getRole(String toLookFor, IGuild guild) {
	toLookFor = GeneralUtils.trim(toLookFor);
	final String lower = toLookFor.toLowerCase();
	if (lower.matches("@&[0-9]+") || lower.matches("[0-9]+")) {
		final String parse = toLookFor.replaceAll("[<@&>]", "");
		IRole exists = guild.getRoleByID(Long.parseLong(toLookFor.replaceAll("[<@&>]", "")));
		if (exists != null) {
			return exists.getLongID();
		}
	}


	List<IRole> roles = new ArrayList<>();
	List<IRole> rs = guild.getRoles();
	roles.addAll(rs.stream().filter(r -> r.getName().equalsIgnoreCase(lower)).collect(Collectors.toList()));
	roles.addAll(rs.stream().filter(r -> r.getName().toLowerCase().contains(lower)).collect(Collectors.toList()));
	final StringBuilder builder = new StringBuilder(); // DEBUG
	roles.forEach(r -> builder.append(r.getName()).append(", ")); // DEBUG
	if (!roles.isEmpty()) {
		return roles.get(0).getLongID();
	}

	return 0;
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:25,代码来源:RoleUtils.java

示例2: loadPermissions

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
public void loadPermissions(List<IGuild> server) {
    try {
        DRIVER.createNewFile(PERMFILE);
        HashMap<String, Object> values = DRIVER.getAllKeysWithValues(PERMFILE);
        for (String roleid : values.keySet()) {
            for (IGuild serverinstance : server) {
                IRole role = serverinstance.getRoleByID(Long.valueOf(roleid));
                if (role != null) {
                    ArrayList<String> permission = new ArrayList<>();
                    JSONArray jArray = (JSONArray) values.get(roleid);
                    if (jArray != null) {
                        for (int i = 0; i < jArray.length(); i++) {
                            if (!jArray.get(i).toString().equalsIgnoreCase("null")) {
                                permission.add(jArray.get(i).toString());
                            }
                        }
                    }
                    grouppermissions.put(role, permission);
                    for (String perm : permission) {
                        Console.debug("Permission: " + perm);
                        for (Command command : COMMAND.getCommandByPermission(perm)) {
                            permissions.put(command, perm);
                        }
                    }
                }
            }
        }
    } catch (Exception ex) {
        Console.error("Failed to load Permissions");
        Console.error(ex);
    }
}
 
开发者ID:ModdyLP,项目名称:MoMuOSB,代码行数:33,代码来源:PermissionController.java

示例3: mentionToRole

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
/**
 * Concerts a role mention to a role
 *
 * @param mention The channel mention
 * @param guild   The guild the role is in
 * @return IRole, or null if there is no such role in the guild or the mention was malformed
 */
public static IRole mentionToRole(String mention, IGuild guild) {
    mention = mention.replace("<&", "").replace(">", "");
    return guild.getRoleByID(mention);
}
 
开发者ID:ArsenArsen,项目名称:ABot,代码行数:12,代码来源:Parsing.java


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