Java 类net.dv8tion.jda.core.entities.User 实例源码

项目:pokeraidbot    文件:RemoveSignUpCommand.java   
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String userName = user.getName();
    final Locale localeForUser = localeService.getLocaleForUser(user);
    String gymName = commandEvent.getArgs();
    final Gym gym = gymRepository.search(user, gymName, config.getRegion());
    final Raid raid = raidRepository.getActiveRaidOrFallbackToExRaid(gym, config.getRegion(), user);
    final SignUp removed = raid.remove(user, raidRepository);
    if (removed != null) {
        commandEvent.reactSuccess();
        removeOriginMessageIfConfigSaysSo(config, commandEvent);
    } else {
        final String message =
                localeService.getMessageFor(LocaleService.NO_SIGNUP_AT_GYM, localeForUser, userName, gym.getName());
        replyErrorBasedOnConfig(config, commandEvent, new UserMessedUpException(user, message));
    }
}
项目:krobot    文件:UserUtils.java   
/**
 * Get the private channel of the given user. Opens it if needed.
 *
 * @param user The user private channel
 *
 * @return The private channel
 *
 * @deprecated Deprecated in JDA, use now {@link User#openPrivateChannel()} directly.
 */
public static PrivateChannel privateChannel(@NotNull User user)
{
    if (!user.hasPrivateChannel())
    {
        try
        {
            return user.openPrivateChannel().submit().get();
        }
        catch (InterruptedException | ExecutionException ignored)
        {
        }
    }

    return user.getPrivateChannel();
}
项目:avaire    文件:UserIdCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    User user = message.getAuthor();
    if (args.length > 0) {
        user = MentionableUtil.getUser(message, args);
    }

    if (user == null) {
        return sendErrorMessage(message, "I found no users with the name or ID of `%s`", args[0]);
    }

    MessageFactory.makeSuccess(message, ":id: of the user **:target** is `:targetid`")
        .set("target", user.getAsMention())
        .set("targetid", user.getId())
        .queue();
    return true;
}
项目:pokeraidbot    文件:AlterRaidCommand.java   
private void checkIfInputIsValidAndUserHasRights(CommandEvent commandEvent, Config config, User user, Raid raid,
                                                 LocalDateTime newDateTime) {
    verifyIsModOrHasGroupForRaid(commandEvent, user, raid, config);
    assertTimeInRaidTimespan(user, newDateTime, raid, localeService);
    assertGroupTimeNotBeforeNow(user, newDateTime, localeService);
    if (raidRepository.existsGroupForRaidAt(raid, newDateTime)) { // Check for any user
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.GROUP_NOT_ADDED,
                localeService.getLocaleForUser(user), String.valueOf(raid)));
    }

    if (raidRepository.hasManyGroupsForRaid(user, raid)) {
        throw new UserMessedUpException(user, localeService.getMessageFor(
                LocaleService.MANY_GROUPS_FOR_RAID,
                localeService.getLocaleForUser(user), String.valueOf(raid)));
    }
}
项目:Ducky-Mc-Duckerson    文件:DeleteCommandCS.java   
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();
    if (hasPermission(author)) {
        //toggle command
        Boolean delCmd = !dbMan.getDeleteCommand(guildID);
        try {
            dbMan.setDeleteCommand(guildID, delCmd);
            if (!delCmd) {
                message.addReaction(":heavy_check_mark:").queue();
            }
        } catch (SQLException e) {
            channel.sendMessage(localize(channel, "command.toggle_delete.error.sql")).queue();
        }


    }

}
项目:Ducky-Mc-Duckerson    文件:WerewolfJoinCS.java   
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();

    if (!dbMan.isWerewolfOn(guildID)) {
        //Werewolf is turned off for this guild, so ignore the command
        return;
    }

    if (hasPermission(author)) {
        //check to make sure that we're in a gamestarted state
        GameState gs = ww.getWerewolfGameState(guildID);
        if (gs != null && gs == GameState.GAMESTART) {
            ww.joinGame(guildID, author);
        }
    }
}
项目:pokeraidbot    文件:PokemonTrackingTarget.java   
private void sendPrivateMessage(User user, String content)
{
    // openPrivateChannel provides a RestAction<PrivateChannel>
    // which means it supplies you with the resulting channel
    user.openPrivateChannel().queue((channel) ->
    {
        // value is a parameter for the `accept(T channel)` method of our callback.
        // here we implement the body of that method, which will be called later by JDA automatically.
        try {
            channel.sendMessage(content).queue(m -> {}, m ->{
                LOGGER.warn("Could not send private message for tracking " + this + ": " + m.getMessage());
            });
            // here we access the enclosing scope variable -content-
            // which was provided to sendPrivateMessage(User, String) as a parameter
        } catch (Throwable t) {
            LOGGER.warn("Could not send private message for tracking " + this + ": " + t.getMessage());
        }
    });
}
项目:zlevels    文件:AutoRole.java   
public static void assignRole(UserData data) {
    User user = ZLevels.jda.getUserById(data.getUserId());
    Guild guild = ZLevels.jda.getGuildById(Config.SERVER);
    int level = data.getLevel();

    for (int requiredLevel : roles.keySet()) {
        if (level < requiredLevel) return;

        Member member = guild.getMember(user);
        Role role = guild.getRolesByName(roles.get(requiredLevel).getString("name"), false).get(0);

        if (member == null || role == null) return;
        if (member.getRoles().contains(role)) return;

        try {
            guild.getController().addRolesToMember(member, role).queue();
        } catch (Exception e) {
            ZLogger.warn("Could not assign role to " + user.getName() + "!");
        }
    }
}
项目:Saber-Bot    文件:MessageUtilities.java   
/**
 * sends a message to a private message channel, opening the channel before use
 *, asynchronous (non-blocking)
 * @param content the message to send as a string
 * @param user the user to send the private message to
 * @param action a non null Consumer will do operations on the results returned
 */
public static void sendPrivateMsg(String content, User user, Consumer<Message> action )
{
    if (content.isEmpty()) return;
    if (user.isBot()) return;

    try
    {
        user.openPrivateChannel().queue(privateChannel -> sendMsg(content, privateChannel, action), null);
    }
    catch (PermissionException ignored) { }
    catch (Exception e)
    {
        Logging.exception( MessageUtilities.class, e );
    }
}
项目:GensokyoBot    文件:DiscordUtil.java   
public static User getUserFromBearer(JDA jda, String token) {
    try {
        JSONObject user =  Unirest.get(Requester.DISCORD_API_PREFIX + "/users/@me")
                .header("Authorization", "Bearer " + token)
                .header("User-agent", USER_AGENT)
                .asJson()
                .getBody()
                .getObject();

        if(user.has("id")){
            return jda.retrieveUserById(user.getString("id")).complete(true);
        }
    } catch (UnirestException | RateLimitedException ignored) {}

    return null;
}
项目:quorrabot    文件:DiscordAPI.java   
private void handleMessages(MessageReceivedEvent event) {
    String channelName = event.getChannel().getName();
    String username = event.getAuthor().getName();
    String message = event.getMessage().getContent();
    String messageId = event.getMessage().getId();
    Channel channel = event.getTextChannel();
    User sender = event.getAuthor();
    Boolean isAdmin = PermissionUtil.checkPermission(channel, event.getMember(), Permission.ADMINISTRATOR);

    com.gmt2001.Console.out.println("[DISCORD] [#" + channelName + "] " + username.toLowerCase() + ": " + message);

    // Be sure that this is commented out before a release back into the master branch!  
    /*
    if (message.equals("!testjoin") && isAdmin) { 
        EventBus.instance().post(new DiscordJoinEvent(event.getMember()));
    }
    */

    if (message.startsWith("!")) {
        commandEvent(sender, channel, message, isAdmin);
    }

    EventBus.instance().postAsync(new DiscordMessageEvent(sender, channel, message, messageId, isAdmin));
}
项目:Minecordbot    文件:HelpCmd.java   
@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());
        }
    }
}
项目:Amme    文件:say.java   
@Override
public void action(String[] args, GuildMessageReceivedEvent event) throws ParseException, IOException {
    if (core.permissionHandler.check(4, event)) return;

    String message = String.join(" ", args).split("@")[0];
    User memb = event.getMessage().getMentionedUsers().size() > 0 ?  event.getMessage().getMentionedUsers().get(0) : null;
    User author = event.getAuthor();
    TextChannel chan = event.getChannel();

    if (args.length < 2 || memb == null) {
        chan.sendMessage(new EmbedBuilder().setColor(Color.red).setDescription(help()).build()).queue();
        return;
    }
    event.getMessage().delete().queue();

    memb.openPrivateChannel().queue(pc -> pc.sendMessage(message.substring(0, message.length() - 1)).queue());
}
项目:GabrielBot    文件:GameCommands.java   
@Command(
        name = "trivia",
        description = "Play trivia",
        usage = "`>>trivia`: Play trivia",
        permission = CommandPermission.USER,
        category = CommandCategory.GAME
)
public static void trivia(@Argument("channel") TextChannel channel, @Argument("author") User author) {
    if(check(channel)) return;
    OpenTriviaDatabase.Question q = OpenTriviaDatabase.random();
    if(q == null) {
        channel.sendMessage("Error getting a question from open trivia database").queue();
        return;
    }
    TLongSet players = new TLongHashSet();
    players.add(author.getIdLong());
    EventManagerThread.current().newThread(()->{
        try {
            Thread.sleep(100);
        } catch(InterruptedException e) {
            return;
        }
        InteractiveOperations.create(channel.getIdLong(), 120, new Trivia(channel, players, q));
    }, "Game Starter").start();
}
项目:legendarybot    文件:WoWLinkPlugin.java   
/**
 * Retrieve all characters of a player in a specific guild
 * @param user The user to get the characters from
 * @param guild The guild to retrieve the characters from.
 * @return A List containing all characters of a player that belong to a specific guild.
 */
public List<String> getUserCharactersInGuild(User user, Guild guild) {
    List<String> charactersList = new ArrayList<>();
    try {
        Connection conn = getBot().getDatabase().getConnection();
        PreparedStatement statement = conn.prepareStatement("SELECT * FROM user_characters WHERE user_id=? AND guildName=? AND region=?");
        statement.setString(1,user.getId());
        statement.setString(2, getBot().getGuildSettings(guild).getGuildName());
        statement.setString(3,getBot().getGuildSettings(guild).getRegionName());
        ResultSet set = statement.executeQuery();
        while(set.next()) {
            charactersList.add(set.getString("characterName"));
        }
        set.close();
        statement.close();
        conn.close();
    } catch (SQLException e) {
        e.printStackTrace();
        getBot().getStacktraceHandler().sendStacktrace(e);
    }
    return charactersList;
}
项目:avaire    文件:UserAvatarCommand.java   
@Override
public boolean onCommand(Message message, String[] args) {
    User user = message.getAuthor();
    if (args.length > 0) {
        user = MentionableUtil.getUser(message, args);
    }

    if (user == null) {
        return sendErrorMessage(message, "I found no users with the name or ID of `%s`", args[0]);
    }

    String avatarUrl = generateAvatarUrl(user);
    MessageFactory.makeEmbeddedMessage(message.getChannel())
        .setTitle(user.getName() + "#" + user.getDiscriminator() + "'s Avatar", avatarUrl)
        .setImage(avatarUrl)
        .queue();

    return true;
}
项目:pokeraidbot    文件:AlterRaidCommand.java   
private Set<EmoticonSignUpMessageListener> getListenersForUser(User user, Raid raid) {
    Set<EmoticonSignUpMessageListener> listenersToCheck;
    listenersToCheck = new HashSet<>();
    for (Object o : botService.getBot().getRegisteredListeners()) {
        if (o instanceof EmoticonSignUpMessageListener) {
            EmoticonSignUpMessageListener listener = (EmoticonSignUpMessageListener) o;
            final String raidId = raid.getId();
            final boolean isCorrectRaid = raidId.equals(listener.getRaidId());
            final boolean isUsersGroup = user.getId().equals(listener.getUserId());
            if (isCorrectRaid && isUsersGroup) {
                listenersToCheck.add(listener);
                break; // If we found user's group, that's the one to change primarily
            }
        }
    }
    return listenersToCheck;
}
项目:BullyBot    文件:QueueManager.java   
/**
 * Adds the player to a specific queue, if the player has just finished, adds to that queue's waitlist instead.
 * 
 * @param player the player being added
 * @param index the one-based index of the queue
 * @see Queue
 */
public void addPlayerToQueue(User player, Integer index) {
    Integer i = --index;
    if (doesQueueExist(i)) {
        if (!isPlayerIngame(player)) {
            Queue q = queueList.get(i);
            if (!justFinished.contains(player)) {
                q.add(player);
            } else {
                q.addToWaitList(player);
            }
        } else {
            throw new InvalidUseException("You are already in-game");
        }

    } else {
        throw new DoesNotExistException("Queue");
    }
}
项目:pokeraidbot    文件:RaidStatisticsTest.java   
@Test
@Ignore //  Not done
public void updateStatisticsWithRaid() throws Exception {
    RaidStatistics statistics = new RaidStatistics();
    Raid raid = new Raid(pokemonRepository.getByName("Groudon"), clockService.getCurrentDateTime(),
            gymRepository.findByName("Blenda", uppsalaRegion), localeService, uppsalaRegion);
    User user = mock(User.class);
    when(user.getName()).thenReturn("test");
    raid.signUp(user, 4, currentTime.plusMinutes(10), repo);
    statistics.updateForRaid(raid);
    Map<String, ServerRaidStatistics> stats = statistics.getAll();
    final ServerRaidStatistics statsForUppsala = stats.get(uppsalaRegion);
    final ServerRaidStatistics expectedStats = new ServerRaidStatistics();
    // TEST NOT DONE YET
    // assertThat(statsForUppsala, is(expectedStats));
}
项目:BullyBot    文件:Queue.java   
/**
 * Randomizes players waiting after finishing a game into queue
 * 
 * @param players the players to allow to add to queue
 */
public void addPlayersWaiting(List<User> players) {
    if(waitList.size() > 0){
        Random random = new Random();
        List<User> playersToAdd = new ArrayList<User>(players);
        while(playersToAdd.size() > 0){
            Integer i = random.nextInt(playersToAdd.size());
            User player = playersToAdd.get(i);
            if(waitList.contains(player)){
                add(player);
                waitList.remove(player);
            }
            playersToAdd.remove(player);
        }
    }
}
项目:Endless    文件:ProfileDataManager.java   
public boolean hasAProfile(User user)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT * FROM PROFILES WHERE USER_ID = %s", user.getId())))
        {
            return results.next();
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return false;
    }
}
项目:Endless    文件:GuildUtils.java   
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());
}
项目:Endless    文件:DonatorsDataManager.java   
public String getAmount(User user)
{
    try
    {
        Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        statement.closeOnCompletion();

        try(ResultSet results = statement.executeQuery(String.format("SELECT user_id, donated_amount FROM PROFILES WHERE user_id = %s", user.getId())))
        {
            if(results.next())
                return results.getString("donated_amount");
            else
                return null;
        }
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
项目:Endless    文件:DonatorsDataManager.java   
public List<User> getUsersThatDonated(JDA jda)
{
    try
    {
        Statement statement = connection.createStatement();
        statement.closeOnCompletion();
        List<User> users;

        try(ResultSet results = statement.executeQuery("SELECT user_id, donated_amount FROM PROFILES"))
        {
            users = new LinkedList<>();
            while(results.next())
            {
                User u = jda.retrieveUserById(results.getLong("user_id")).complete();
                if(hasDonated(u))
                    users.add(u);
            }
        }
        return users;
    }
    catch(SQLException e)
    {
        LOG.warn(e.toString());
        return null;
    }
}
项目:Minecordbot    文件:DSync.java   
@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"));
    }
}
项目:pokeraidbot    文件:NewRaidCommand.java   
@Override
protected void executeWithConfig(CommandEvent commandEvent, Config config) {
    final User user = commandEvent.getAuthor();
    final String[] args = commandEvent.getArgs().replaceAll("\\s{1,3}", " ").split(" ");
    if (args.length < 3) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.BAD_SYNTAX,
                localeService.getLocaleForUser(user), "!raid new ho-oh 10:00 solna platform"));
    }
    String pokemonName = args[0];
    final Pokemon pokemon = pokemonRepository.search(pokemonName, user);
    String timeString = args[1];
    LocalTime endsAtTime = Utils.parseTime(user, timeString, localeService);
    LocalDateTime endsAt = LocalDateTime.of(LocalDate.now(), endsAtTime);

    assertTimeNotInNoRaidTimespan(user, endsAtTime, localeService);
    assertTimeNotMoreThanXHoursFromNow(user, endsAtTime, localeService, 2);
    assertCreateRaidTimeNotBeforeNow(user, endsAt, localeService);

    StringBuilder gymNameBuilder = new StringBuilder();
    for (int i = 2; i < args.length; i++) {
        gymNameBuilder.append(args[i]).append(" ");
    }
    String gymName = gymNameBuilder.toString().trim();
    final Gym gym = gymRepository.search(user, gymName, config.getRegion());
    final Raid raid = new Raid(pokemon, endsAt, gym, localeService, config.getRegion());
    raidRepository.newRaid(user, raid, commandEvent.getGuild(), config, "!raid new " +
            raid.getPokemon().getName() + " " + printTimeIfSameDay(raid.getEndOfRaid()) + " " +
            raid.getGym().getName());
    final Locale locale = localeService.getLocaleForUser(user);
    replyBasedOnConfigAndRemoveAfter(config, commandEvent, localeService.getMessageFor(LocaleService.NEW_RAID_CREATED,
            locale, raid.toString(locale)), BotServerMain.timeToRemoveFeedbackInSeconds);
}
项目:Blizcord    文件:Add.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(arg == null) {
        channel.sendMessage(author.getAsMention() + " ``Please specify what I should add to the playlist. Put it behind this command.``").queue();
        return;
    }

    // Join the voice channel of the command author before addToPlaylist() joins the default channel
    Bot.joinVoiceChannel(Bot.getGuild().getMember(author));

    AudioPlayerThread.addToPlaylist(arg, false);
}
项目:Hobbes-v1    文件:Ban.java   
@Override
protected void execute(Input input, Output output) { // TODO: Allow banning users not in guild.
  for (User user : MessageUtils.getUsers(input)) {
    if (user != null) {
      input.getGuild().getController().ban(user, 0);
    }
  }
  output.sendMessage(" :ok_hand: ");
}
项目:quorrabot    文件:DiscordEvent.java   
public DiscordEvent(User user, Channel channel) {
    this.user = user;
    this.channel = channel;
    this.username = user.getName();
    this.discrim = user.getDiscriminator();
    this.channelName = channel.getName();
    this.senderId = user.getId();
    this.sender = (username + "#" + discrim);
    this.mention = "<@" + senderId + ">";
}
项目:JDodoBot    文件:Stats.java   
public static Stats GetStats(User user) {
    for (Stats s : Bot.stats) {
        if (s.belongsTo(user))
            return s;
    }
    return null;
}
项目:Ducky-Mc-Duckerson    文件:TableFlipCS.java   
@Override
public void execute(Member author, User authorUser, MessageChannel channel, Message message, String parameters, Map<String, CommandStructure> commandList) {
    Long guildID = author.getGuild().getIdLong();
    if (hasPermission(author)) {
        channel.sendMessage(author.getEffectiveName() + ": (╯°□°)╯︵ ┻━┻").queue();
        try {
            dbMan.incUserFlipped(guildID, author.getUser().getIdLong());
        } catch (SQLException e) {
            channel.sendMessage(localize(channel, "command.tableflip.error.sql")).queue();
        }
    }
}
项目:JDodoBot    文件:Slot.java   
@Override
public void doYaThing(Message message) {
    User author = message.getAuthor();
    String content = message.getRawContent();
    MessageChannel channel = message.getChannel();
    String commandNParameters[] = DodoStringHandler.getCommandNParameters(content);
    BankAccount temp = new BankAccount("temp");
    boolean exists = false;
    for (BankAccount b : bankAccounts) {
        if (b.getID().equals(author.getId())) {
            exists = true;
            temp = b;
        }
    }
    try {
        if (commandNParameters.length < 2)
            channel.sendMessage("```" + prefix + usage + "```").complete();
        else if (exists && temp.getBalance() >= Double.parseDouble(commandNParameters[1])) {
            if (Double.parseDouble(commandNParameters[1]) > -1)
                SlotMashina.slotMashinas(Double.parseDouble(commandNParameters[1]), channel, temp);
            else
                channel.sendMessage("Can't slot that!").complete();
        } else {
            if (!exists) {
                channel.sendMessage("You have to register! Use `" + prefix + "bank register`").complete();
            } else channel.sendMessage("You are too poor!").complete();
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
        log.log("ERROR: " + e.getCause() + " " + e.getMessage());
    }
}
项目:Blizcord    文件:Loop.java   
@Override
public void execute(String arg, User author, MessageChannel channel, Guild guild) {
    if(AudioPlayerThread.loop) {
        AudioPlayerThread.loop = false;
        channel.sendMessage(author.getAsMention() + " Looping: ``disabled``").queue();
    } else {
        AudioPlayerThread.loop = true;
        channel.sendMessage(author.getAsMention() + " Looping: ``enabled``").queue();
    }
}
项目:BullyBot    文件:Game.java   
/**
 * Inserts information into the database
 */
private void pickingComplete(){
    setStatus(GameStatus.PLAYING);


    // Insert players in game into database
    for(User u : players){
        Database.insertPlayerGame(u.getIdLong(), timestamp, Long.valueOf(guildId));
    }

    // Update captains
    for(User c : captains){
        if(c != null){
            Database.updatePlayerGameCaptain(c.getIdLong(), timestamp, Long.valueOf(guildId), true);
        }
    }

    // Add player pick order to database
    if(pickMenu != null){
        Integer count = 1;
        for (String id : pickMenu.getPickOrder()) {
            Database.updatePlayerGamePickOrder(Long.valueOf(id), timestamp, Long.valueOf(guildId), count);
            count++;
        }

        // Post teams to pug channel
        if(ServerManager.getServer(guildId).getSettings().postTeams()){
            String s = String.format("`Game: %s`", name);
            ServerManager.getServer(guildId).getPugChannel()
            .sendMessage(Utils.createMessage(s, pickMenu.getPickedTeamsString(), true)).queue();
        }
    }
}
项目:pokeraidbot    文件:RaidRepository.java   
private RaidEntity saveRaid(User raidCreator, Raid raid) {
    final RaidEntity toBeSaved = new RaidEntity(UUID.randomUUID().toString(),
            raid.getPokemon().getName(),
            raid.getEndOfRaid(),
            raid.getGym().getName(),
            raidCreator.getName(),
            raid.getRegion());
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Creating raid: " + toBeSaved);
    }
    return raidEntityRepository.save(toBeSaved);

}
项目:avaire    文件:GoodbyeMessageCommand.java   
private boolean sendExampleMessage(Message message, User user, ChannelTransformer transformer) {
    message.getChannel().sendMessage(
        StringReplacementUtil.parseChannel(message.getTextChannel(),
            StringReplacementUtil.parseUser(user,
                StringReplacementUtil.parseGuild(message.getGuild(),
                    transformer.getGoodbye().getMessage() == null ?
                        "%user% has left **%server%**! :(" :
                        transformer.getGoodbye().getMessage()
                )
            )
        )
    ).queue();

    return true;
}
项目:BullyBot    文件:TeamPickerMenu.java   
public String toString(){
    String names = "";
    if(members.size() > 0){
        for(User m : members){
            names += m.getName() + ", ";
        }
        names = names.substring(0, names.length() - 2);
    }
    return String.format("%s: %s", captain.getName(), names);
}
项目:Supreme-Bot    文件:ArgumentList.java   
public final Member getMember(int index, boolean consume) {
    if (guild == null) {
        return null;
    }
    final String temp = getRaw(index);
    if (temp == null) {
        return null;
    }
    final User user = getUser(index, consume);
    if (user == null) {
        return null;
    }
    return guild.getMember(user);
}
项目:pokeraidbot    文件:AlterRaidCommand.java   
private void assertPermissionToManageThisGroup(User user, RaidGroup raidGroup,
                                               CommandEvent commandEvent, Config config) {
    if (!isUserServerMod(commandEvent, config) && !raidGroup.getCreatorId().equals(user.getId())) {
        throw new UserMessedUpException(user, localeService.getMessageFor(LocaleService.NO_PERMISSION,
                localeService.getLocaleForUser(user)));
    }
}
项目:pokeraidbot    文件:RaidRepository.java   
public Raid getActiveRaidOrFallbackToExRaid(Gym gym, String region, User user) {
    RaidEntity raidEntity = getActiveOrFallbackToExRaidEntity(gym, region);
    if (raidEntity == null) {
        throw new RaidNotFoundException(gym, localeService, user);
    }
    final Raid raid = getRaidInstance(raidEntity);
    return raid;
}