當前位置: 首頁>>代碼示例>>Java>>正文


Java JDA.getUserById方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.JDA.getUserById方法的典型用法代碼示例。如果您正苦於以下問題:Java JDA.getUserById方法的具體用法?Java JDA.getUserById怎麽用?Java JDA.getUserById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.JDA的用法示例。


在下文中一共展示了JDA.getUserById方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: leaveBadGuilds

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static void leaveBadGuilds(JDA jda)
{
    User owner = jda.getUserById(config.getOwnerId());
    jda.getGuilds().stream().filter(g -> {
        if(db.hasSettings(g))
            return false;

        long botCount = g.getMembers().stream().map(m -> m.getUser()).filter(u -> u.isBot()).count();
        if(botCount>20 && ((double)botCount/g.getMembers().size())>.50)
            return true;

        /**if(isABotListGuild(g))
        {
            jda.getUserById("264499432538505217").openPrivateChannel().queue(s -> s.sendMessage("**"+owner.getName()+"#"+owner.getDiscriminator()+"** has a copy of Endless at "+g.getName()));
            return true;
        }*/

        return false;
    }).forEach(g -> g.leave().queue());
}
 
開發者ID:EndlessBot,項目名稱:Endless,代碼行數:21,代碼來源:GuildUtils.java

示例2: doCommand

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
@Override
protected void doCommand(CommandEvent e) {
    EmbedBuilder eb = new EmbedBuilder();
    JDA jda = getMcb().getBot().getJda();
    Color color = Bot.BOT_COLOR; //e.getGuild().getMember(jda.getSelfUser()).getColor()
    eb.setColor(color);
    eb.setDescription(Locale.getCommandsMessage("help.more").f(e.getClient().getPrefix()));
    if (e.getArgs().isEmpty()) {
        eb.setAuthor("Minecordbot Commands", null, null);
        eb.setThumbnail("https://vectr.com/cyrien/k3vhJlcOMS.png?width=168&height=168&select=k3vhJlcOMSpage0");
        eb = listCommands(eb);
        User user = jda.getUserById("193970511615623168");
        if (user != null) {
            eb.setFooter("Questions? contact " + user.getName() + "#" + user.getDiscriminator() + " or join https://discord.cyrien.us", user.getAvatarUrl());
            respond(e, eb.build());
        }
    }
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:19,代碼來源:HelpCmd.java

示例3: getUserById

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static User getUserById(JDA shard, String userId) {
    User user = shard.getUserById(userId);

    if (user == null) {
        user = shard.retrieveUserById(userId).complete();
    }

    return user;
}
 
開發者ID:Samoxive,項目名稱:SafetyJim,代碼行數:10,代碼來源:DiscordUtils.java

示例4: getUserById

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static User getUserById(String id) {
	for (JDA jda : Bot.shards) {
		User user = jda.getUserById(id);
		if (user != null) return user;
	}
	return null;
}
 
開發者ID:Tisawesomeness,項目名稱:Minecord,代碼行數:8,代碼來源:DiscordUtils.java

示例5: getUserById

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
/**
 * Get a user from an ID from all shards
 * @param userId User ID
 * @return User if found, null if not
 */
public User getUserById(long userId) {
	for (JDA j : jdaClients) {
		User u;
		if ((u = j.getUserById(userId)) != null) {
			return u;
		}
	}
	return null;
}
 
開發者ID:paul-io,項目名稱:momo-2,代碼行數:15,代碼來源:Bot.java

示例6: execute

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
    JDA jda = discordService.getJda();
    if (jda == null || !JDA.Status.CONNECTED.equals(jda.getStatus())) {
        throw new RuntimeException("Could not send reminder, not connected!");
    }

    JobDataMap data = jobExecutionContext.getJobDetail().getJobDataMap();

    String userId = data.getString(ATTR_USER_ID);
    String guildId = data.getString(ATTR_GUILD_ID);
    String channelId = data.getString(ATTR_CHANNEL_ID);
    String messageRaw = data.getString(ATTR_MESSAGE);

    MessageChannel channel = null;
    User user = jda.getUserById(userId);
    StringBuilder message = new StringBuilder();
    if (guildId != null) {
        Guild guild = jda.getGuildById(guildId);
        if (guild != null) {
            channel = guild.getTextChannelById(channelId);
            if (user != null && guild.isMember(user)) {
                message.append(user.getAsMention()).append(" ");
            }
        }
    } else {
        channel = jda.getPrivateChannelById(channelId);
    }
    if (channel == null && user != null) {
        channel = user.openPrivateChannel().complete();
    }
    if (channel != null) {
        message.append(messageRaw);
        channel.sendMessage(message.toString()).queue();
    }
}
 
開發者ID:GoldRenard,項目名稱:JuniperBotJ,代碼行數:37,代碼來源:ReminderJob.java

示例7: syncRequest

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
@Command(aliases = "mcbsync", usage = "/mcbsync <Discord user id or Discord username>", desc = "Sync Minecraft and Discord account")
@Permission("minecordbot.discordsync")
public void syncRequest(@Sender CommandSender commandSender, String discordID) {
    JDA jda = Minecordbot.getInstance().getBot().getJda();
    User dUser = StringUtils.isNumeric(discordID) ? jda.getUserById(discordID) : null;
    if (!(commandSender instanceof Player)) {
        commandSender.sendMessage("only players can use this");
        return;
    }
    if (dUser == null)
        dUser = (FinderUtil.findMember(discordID) == null) ? null : FinderUtil.findMember(discordID).getUser();
    if (dUser != null) {
        AuthSession authSession = new AuthSession((Player) commandSender, dUser);
        AuthToken token = authSession.getAuthToken();
        User finalDUser1 = dUser;
        EventWaiter eventWaiter = Minecordbot.getInstance().getEventWaiter();
        dUser.openPrivateChannel().queue(pc -> pc.sendMessage(verificationCode(token)).queue(m -> {
            m.addReaction(CANCEL).complete();
            eventWaiter.waitForEvent(MessageReactionAddEvent.class, e -> e.getReaction().getEmote().getName().equals(CANCEL) && e.getMessageId().equals(m.getId()) && !e.getUser().isBot(), a -> {
                a.getReaction().removeReaction().queue();
                authSession.cancel();
            }, AuthSession.SYNC_TIMEOUT, TimeUnit.MINUTES, authSession::cancel);
            commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6[MCBSync] &rAccount sync &6pending!"));
            commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&',
                    "&6[MCBSync] &rA verification code have been sent to your Discord account " + finalDUser1.getName() + "(" + finalDUser1.getId() + ")"));
        }, t -> {
            commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', cannotSendCode()));
            authSession.cancel();
        }), t -> {
            commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', cannotSendCode()));
            authSession.cancel();
        });
    } else {
        commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&6[MCBSync] &rUser not found"));
    }
}
 
開發者ID:CyR1en,項目名稱:Minecordbot,代碼行數:37,代碼來源:DSync.java

示例8: isMainBotPresent

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static boolean isMainBotPresent(Guild guild) {
    JDA jda = guild.getJDA();
    User other = jda.getUserById(BotConstants.MAIN_BOT_ID);
    return other != null && guild.getMember(other) != null;
}
 
開發者ID:Frederikam,項目名稱:GensokyoBot,代碼行數:6,代碼來源:DiscordUtil.java

示例9: isMusicBotPresent

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static boolean isMusicBotPresent(Guild guild) {
    JDA jda = guild.getJDA();
    User other = jda.getUserById(BotConstants.MUSIC_BOT_ID);
    return other != null && guild.getMember(other) != null;
}
 
開發者ID:Frederikam,項目名稱:GensokyoBot,代碼行數:6,代碼來源:DiscordUtil.java

示例10: isPatronBotPresentAndOnline

import net.dv8tion.jda.core.JDA; //導入方法依賴的package包/類
public static boolean isPatronBotPresentAndOnline(Guild guild) {
    JDA jda = guild.getJDA();
    User other = jda.getUserById(BotConstants.PATRON_BOT_ID);
    return other != null && guild.getMember(other) != null && guild.getMember(other).getOnlineStatus() == OnlineStatus.ONLINE;
}
 
開發者ID:Frederikam,項目名稱:GensokyoBot,代碼行數:6,代碼來源:DiscordUtil.java


注:本文中的net.dv8tion.jda.core.JDA.getUserById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。