本文整理汇总了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;
}
示例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);
}
}
示例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);
}