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


Java IGuild.getUserByID方法代码示例

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


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

示例1: sanitize

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
public static String sanitize(@Nullable IGuild guild, String message) {
    if (message == null) return null;
    if (guild == null) return message;
    
	Matcher matcher = REGEX_MENTION.matcher(message);
	while (matcher.find()) {
	    long id = Long.parseLong(matcher.group(1));
	    String name;
	    if (matcher.group().contains("&")) {
	        name = "the " + MCBot.instance.getRoleByID(id).getName();
	    } else {
	        IUser user = guild.getUserByID(id);
	        if (matcher.group().contains("!")) {
	            name = user.getDisplayName(guild).replaceAll("@", "@\u200B");
	        } else {
	            name = user.getName();
	        }
	    }

		message = message.replace(matcher.group(), name);
    }
    return message.replace("@here", "everyone").replace("@everyone", "everyone").replace("@", "@\u200B");
}
 
开发者ID:tterrag1098,项目名称:MCBot,代码行数:24,代码来源:CommandContext.java

示例2: getGuilds

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
public static List<WebGuild> getGuilds(String userId) {
	List<WebGuild> guilds = new ArrayList<>();
	IUser user = Main.client.getUserByID(Long.valueOf(userId));
	for (IGuild g : Main.client.getGuilds()) {
		if (g.getUserByID(Long.valueOf(userId)) != null) {
			WebGuild wg = new WebGuild().fromGuild(g);
			wg.setManageServer(PermissionChecker.hasManageServerRole(g, user));
			wg.setDiscalRole(PermissionChecker.hasSufficientRole(g, user));
			guilds.add(wg);
		}
	}
	return guilds;
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:14,代码来源:GuildUtils.java

示例3: getUser

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
/**
 * Grabs a user from a string
 *
 * @param toLookFor The String to look with
 * @param guild     The guild
 * @return The user if found, null otherwise
 */
public static long getUser(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("[<@!>]", "");
		IUser exists = guild.getUserByID(Long.parseLong(toLookFor.replaceAll("[<@!>]", "")));
		if (exists != null) {
			return exists.getLongID();
		}
	}


	List<IUser> users = new ArrayList<>();
	List<IUser> us = guild.getUsers();
	users.addAll(us.stream().filter(u -> u.getName().equalsIgnoreCase(lower)).collect(Collectors.toList()));
	users.addAll(us.stream().filter(u -> u.getName().toLowerCase().contains(lower)).collect(Collectors.toList()));
	users.addAll(us.stream().filter(u -> (u.getName() + "#" + u.getDiscriminator()).equalsIgnoreCase(lower)).collect(Collectors.toList()));
	users.addAll(us.stream().filter(u -> u.getDiscriminator().equalsIgnoreCase(lower)).collect(Collectors.toList()));
	users.addAll(us.stream().filter(u -> u.getDisplayName(guild).equalsIgnoreCase(lower)).collect(Collectors.toList()));
	users.addAll(us.stream().filter(u -> u.getDisplayName(guild).toLowerCase().contains(lower)).collect(Collectors.toList()));


	if (!users.isEmpty()) {
		return users.get(0).getLongID();
	}

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

示例4: getIUser

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
public static IUser getIUser(String toLookFor, IMessage m, IGuild guild) {
	toLookFor = toLookFor.trim();
	final String lower = toLookFor.toLowerCase();

	IUser res = null;

	if (m != null && !m.getMentions().isEmpty())
		res = m.getMentions().get(0);

	if (toLookFor.matches("<@!?[0-9]+>")) {
		IUser u = guild.getUserByID(Long.parseUnsignedLong(toLookFor.replaceAll("[^0-9]", "")));
		if (u != null) {
			return u;
		}
	}

	List<IUser> users = guild.getUsers().stream()
			.filter(u -> u.getName().toLowerCase().contains(lower)
					|| u.getName().equalsIgnoreCase(lower) || u.getStringID().equals(lower)
					|| u.getDisplayName(guild).toLowerCase().contains(lower)
					|| u.getDisplayName(guild).equalsIgnoreCase(lower))
			.collect(Collectors.toList());
	if (!users.isEmpty())
		res = users.get(0);

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

示例5: getUserFromID

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
private static IUser getUserFromID(String id, IGuild guild) {
	try {
		return guild.getUserByID(Long.parseUnsignedLong(id));
	} catch (Exception e) {
		//Ignore. Probably invalid ID.
		return null;
	}
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:9,代码来源:UserUtils.java

示例6: processCommand

import sx.blah.discord.handle.obj.IGuild; //导入方法依赖的package包/类
@Override
public void processCommand (IMessage message, String[] params) {

    IUser user = null;
    IGuild guild = null;

    // Just user
    if (params.length == 2) {

        guild = message.getGuild();
        user = guild.getUserByID(Long.parseUnsignedLong(params[1]));
    }

    // Guild and user
    else if (params.length == 3) {

        guild = MMDBot.instance.getGuildByID(Long.parseUnsignedLong(params[1]));

        if (guild != null) {
            user = guild.getUserByID(Long.parseUnsignedLong(params[2]));
        }
    }

    if (user != null) {
        Utilities.sendMessage(message.getChannel(), new MessageUser(user, guild).build());
    }
    else {
        Utilities.sendMessage(message.getChannel(), this.getDescription());
    }

    System.out.println(params.length + " - " + user != null);
}
 
开发者ID:MinecraftModDevelopment,项目名称:MMDBot,代码行数:33,代码来源:CommandUser.java


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