public static AudioTrack loadTrack(AudioPlayerManager manager, String identifier) throws Exception { CompletableFuture<AudioTrack> result = new CompletableFuture<>(); manager.loadItem(identifier, new FunctionalResultHandler( result::complete, (playlist) -> result.completeExceptionally(new IllegalArgumentException()), () -> result.completeExceptionally(new NoSuchElementException()), result::completeExceptionally )); return result.get(10, TimeUnit.SECONDS); }
@Override public void noMatches() { if (verbose) { if (isSearch) { context.reply("No song matches found! Usage: `{{prefix}}play <link or youtube video title>` or " + "`{{prefix}}soundcloud <soundcloud song title>`"); if (context.getEvent().getGuild().getAudioManager().isConnected() && musicManager.getPlayer().getPlayingTrack() == null && musicManager.getScheduler().getQueue().isEmpty()) { musicManager.getConnector().closeConnection(); } } else if (allowSearch) { this.isSearch = true; playerManager.loadItem("ytsearch: " + String.join(" ", context.getArgs()), this); } } }
playerManager.loadItem(song, handler);
playerManager.loadItem(url, handler);
playerManager.loadItem(String.join(" ", context.getArgs()), handler); if (!musicManager.getState().isConnectionOpen()) { musicManager.getConnector().openConnection(channel, context.getEvent().getAuthor());