use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project Ardent by adamint.
the class Queue method noArgs.
@Override
public void noArgs(Guild guild, MessageChannel channel, User user, Message message, String[] args) throws Exception {
StringBuilder sb = new StringBuilder();
String queuedBy = "queued by";
sb.append("__Music Queue__\n");
BlockingQueue<ArdentTrack> queue = getGuildAudioPlayer(guild, channel).scheduler.manager.getQueue();
Iterator<ArdentTrack> iterator = queue.iterator();
int current = 1;
ArrayList<AudioTrack> trackList = new ArrayList<>();
while (iterator.hasNext()) {
ArdentTrack ardentTrack = iterator.next();
AudioTrack track = ardentTrack.getTrack();
trackList.add(track);
sb.append("#" + current + ": " + track.getInfo().title + ": " + track.getInfo().author + " " + getDuration(track) + "\n *" + queuedBy + " " + GuildUtils.getShard(guild).jda.getUserById(ardentTrack.getAuthor()).getName() + "*\n");
current++;
}
if (current == 1) {
sb.append("There aren't any songs in the queue!");
}
sendTranslatedMessage(sb.toString(), sendTo(channel, guild), user);
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project DiscordBot by LXGaming.
the class NowPlayingCommand method execute.
@Override
public void execute(TextChannel textChannel, Member member, Message message, List<String> arguments) {
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.DEFAULT);
AudioTrack audioTrack = DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack();
if (audioTrack == null) {
embedBuilder.setTitle("Nothing is currently playing.", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
return;
}
embedBuilder.addField("Now playing", audioTrack.getInfo().title, false);
embedBuilder.setFooter(DiscordUtil.getTimestamp(audioTrack.getPosition()) + " / " + DiscordUtil.getTimestamp(audioTrack.getDuration()), null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project DiscordBot by LXGaming.
the class AudioPlayerLoadResultHandler method playlistLoaded.
@Override
public void playlistLoaded(AudioPlaylist audioPlaylist) {
for (Iterator<AudioTrack> iterator = audioPlaylist.getTracks().iterator(); iterator.hasNext(); ) {
AudioTrack audioTrack = iterator.next();
if (audioTrack == null) {
continue;
}
Audio audio = new Audio(getTextChannel(), getMember(), audioTrack);
DiscordBot.getInstance().getDiscord().getAudioQueue().getQueue().add(audio);
if (DiscordBot.getInstance().getDiscord().getAudioPlayer().getPlayingTrack() == null) {
DiscordBot.getInstance().getDiscord().getAudioQueue().playNext();
} else {
LogHelper.debug("'" + audio.getAudioTrack().getInfo().title + "' Has been added to the queue.");
}
audio = null;
}
LogHelper.debug(audioPlaylist.getTracks().size() + " Songs have been added to the queue.");
EmbedBuilder embedBuilder = new EmbedBuilder();
embedBuilder.setAuthor(textChannel.getJDA().getSelfUser().getName(), null, textChannel.getJDA().getSelfUser().getEffectiveAvatarUrl());
embedBuilder.setColor(DiscordUtil.SUCCESS);
embedBuilder.setTitle(audioPlaylist.getTracks().size() + " Songs have been added to the queue.", null);
DiscordBot.getInstance().getDiscord().getMessageSender().sendMessage(textChannel, embedBuilder.build(), true);
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project legendarybot by greatman.
the class MusicManager method loadAndPlay.
/**
* Load a song
* @param channel The channel to send the alert in.
* @param trackUrl The song URL
* @param voiceChannel the voice channel to play the music in.
*/
public void loadAndPlay(final TextChannel channel, final String trackUrl, VoiceChannel voiceChannel) {
GuildMusicManager musicManager = getGuildAudioPlayer(channel.getGuild());
playerManager.loadItemOrdered(musicManager, trackUrl, new AudioLoadResultHandler() {
@Override
public void trackLoaded(AudioTrack track) {
channel.sendMessage("Adding to queue " + track.getInfo().title).queue();
play(channel.getGuild(), musicManager, track, voiceChannel);
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
AudioTrack firstTrack = playlist.getSelectedTrack();
if (firstTrack == null) {
firstTrack = playlist.getTracks().get(0);
}
channel.sendMessage("Adding to queue " + firstTrack.getInfo().title + " (first track of playlist " + playlist.getName() + ")").queue();
play(channel.getGuild(), musicManager, firstTrack, voiceChannel);
}
@Override
public void noMatches() {
channel.sendMessage("Nothing found by " + trackUrl).queue();
}
@Override
public void loadFailed(FriendlyException exception) {
channel.sendMessage("Could not play: " + exception.getMessage()).queue();
}
});
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project Rubicon by Rubicon-Bot.
the class MusicManager method sendQueue.
public Message sendQueue() {
if (!isBotInVoiceChannel())
return message(error("Error!", "Bot is not in a voice channel."));
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(Colors.COLOR_PRIMARY);
builder.setTitle("Queue");
StringBuilder content = new StringBuilder();
for (AudioTrack track : getCurrentMusicManager().getScheduler().getQueue()) {
content.append(":small_orange_diamond: [" + track.getInfo().title + "](" + track.getInfo().uri + ")\n");
}
builder.setDescription(content.toString());
parsedCommandInvocation.getMessage().getTextChannel().sendMessage(builder.build()).queue();
return null;
}
Aggregations