use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project Rubicon by Rubicon-Bot.
the class MusicSearchResult method generateEmbed.
public EmbedBuilder generateEmbed() {
EmbedBuilder builder = new EmbedBuilder();
builder.setColor(Colors.COLOR_PRIMARY);
int i = 0;
StringBuilder description = new StringBuilder();
for (AudioTrack track : trackList) {
description.append(emotes[i]).append(" [").append(track.getInfo().title).append("](").append(track.getInfo().uri).append(")\n\n");
i++;
}
builder.setFooter("Type in your choose. <1-5> (After 15 seconds the request will be deleted)", null);
builder.setDescription(description.toString());
return builder;
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project MantaroBot by Mantaro.
the class AudioLoader method loadSingle.
private void loadSingle(AudioTrack audioTrack, boolean silent) {
AudioTrackInfo trackInfo = audioTrack.getInfo();
audioTrack.setUserData(event.getAuthor().getId());
DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
DBUser dbUser = MantaroData.db().getUser(event.getMember());
GuildData guildData = dbGuild.getData();
String title = trackInfo.title;
long length = trackInfo.length;
long queueLimit = !Optional.ofNullable(dbGuild.getData().getMusicQueueSizeLimit()).isPresent() ? MAX_QUEUE_LENGTH : dbGuild.getData().getMusicQueueSizeLimit();
int fqSize = guildData.getMaxFairQueue();
if (musicManager.getTrackScheduler().getQueue().size() > queueLimit && !dbUser.isPremium() && !dbGuild.isPremium()) {
if (!silent)
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Surpassed queue song limit!", title)).queue(message -> message.delete().queueAfter(30, TimeUnit.SECONDS));
return;
}
if (audioTrack.getInfo().length > MAX_SONG_LENGTH && !dbUser.isPremium() && !dbGuild.isPremium()) {
event.getChannel().sendMessage(String.format(":warning: Could not queue %s: Track is longer than 32 minutes! (%s)", title, AudioUtils.getLength(length))).queue();
return;
}
// Comparing if the URLs are the same to be 100% sure they're just not spamming the same url over and over again.
if (musicManager.getTrackScheduler().getQueue().stream().filter(track -> track.getInfo().uri.equals(audioTrack.getInfo().uri)).count() > fqSize && !silent) {
event.getChannel().sendMessage(EmoteReference.ERROR + String.format("**Surpassed fair queue level of %d (Too many songs which are exactly equal)**", fqSize + 1)).queue();
return;
}
musicManager.getTrackScheduler().queue(audioTrack, insertFirst);
musicManager.getTrackScheduler().setRequestedChannel(event.getChannel().getIdLong());
if (!silent) {
event.getChannel().sendMessage(new MessageBuilder().append(String.format("\uD83D\uDCE3 Added to queue -> **%s** **(%s)**", title, AudioUtils.getLength(length))).stripMentions(event.getGuild(), Message.MentionType.EVERYONE, Message.MentionType.HERE).build()).queue();
}
MantaroBot.getInstance().getStatsClient().increment("tracks_loaded");
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project MantaroBot by Mantaro.
the class MusicCmds method skipahead.
@Subscribe
public void skipahead(CommandRegistry cr) {
cr.register("skipahead", new SimpleCommand(Category.MUSIC) {
@Override
protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
if (args.length == 0) {
onHelp(event);
return;
}
GuildMusicManager manager = MantaroBot.getInstance().getAudioManager().getMusicManager(event.getGuild());
if (manager.getAudioPlayer().getPlayingTrack() == null) {
event.getChannel().sendMessage(EmoteReference.ERROR + "I'm not currently playing anything").queue();
return;
}
if (isDJ(event.getMember())) {
try {
long amt = Utils.parseTime(args[0]);
if (amt < 0) {
event.getChannel().sendMessage(EmoteReference.ERROR + "Positive integers only").queue();
return;
}
AudioTrack track = manager.getAudioPlayer().getPlayingTrack();
long position = track.getPosition();
if (position + amt > track.getDuration()) {
event.getChannel().sendMessage(EmoteReference.ERROR + "You can't skip past the duration of a song").queue();
return;
}
track.setPosition(position + amt);
event.getChannel().sendMessage(EmoteReference.CORRECT + "Skipped ahead to " + AudioUtils.getLength(position + amt) + ".").queue();
} catch (NumberFormatException ex) {
event.getChannel().sendMessage(EmoteReference.ERROR + "You need to provide a valid query.").queue();
}
} else
event.getChannel().sendMessage(EmoteReference.ERROR + "You need to be a music DJ to use this command!").queue();
}
@Override
public MessageEmbed help(GuildMessageReceivedEvent event) {
return helpEmbed(event, "Skip Ahead Command").addField("Description", "Fast forward the current song a specified amount of time", false).addField("Usage", "~>skipahead <time>\nTime is in this format: 1m29s (1 minute and 29s)", false).build();
}
});
cr.registerAlias("skipahead", "forward");
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project c0debaseBot by Biospheere.
the class MusicManager method loadTrack.
public void loadTrack(TextChannel channel, User requester, String trackUrl) {
Guild guild = channel.getGuild();
loadTrack(guild, trackUrl, new AudioLoadResultHandler() {
@Override
public void trackLoaded(AudioTrack track) {
queue(guild, track);
EmbedBuilder eb = getEmbed(guild, requester).setAuthor("Track geladen", trackUrl.startsWith("http") ? trackUrl : null, bot.getJda().getSelfUser().getEffectiveAvatarUrl());
AudioTrackInfo trackInfo = track.getInfo();
String length;
if (TimeUnit.MILLISECONDS.toHours(trackInfo.length) >= 24) {
length = String.format("%dd %02d:%02d:%02d", TimeUnit.MILLISECONDS.toDays(trackInfo.length), TimeUnit.MILLISECONDS.toHours(trackInfo.length) % 24, TimeUnit.MILLISECONDS.toMinutes(trackInfo.length) % 60, TimeUnit.MILLISECONDS.toSeconds(trackInfo.length) % 60);
} else {
length = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(trackInfo.length) % 24, TimeUnit.MILLISECONDS.toMinutes(trackInfo.length) % 60, TimeUnit.MILLISECONDS.toSeconds(trackInfo.length) % 60);
}
eb.addField(trackInfo.title, "`" + trackInfo.author + " - " + (trackInfo.isStream ? "STREAM" : length) + "`", false);
channel.sendMessage(eb.build()).queue();
}
@Override
public void playlistLoaded(AudioPlaylist playlist) {
List<AudioTrack> tracks = playlist.getTracks();
if (playlist.isSearchResult()) {
trackLoaded(tracks.get(0));
return;
}
EmbedBuilder eb = getEmbed(guild, requester).setAuthor("Playlist geladen", playlist.isSearchResult() ? null : trackUrl, bot.getJda().getSelfUser().getEffectiveAvatarUrl());
eb.addField(playlist.getName(), "`" + tracks.size() + " Videos gefunden`", false);
channel.sendMessage(eb.build()).queue();
queue(guild, tracks);
nextTrack(guild, false);
}
@Override
public void noMatches() {
channel.sendMessage(getEmbed(guild, requester).setAuthor("Nichts gefunden", null, bot.getJda().getSelfUser().getEffectiveAvatarUrl()).addField("Keine Übereinstimmung", "`" + trackUrl + "`", false).build()).queue();
}
@Override
public void loadFailed(FriendlyException exception) {
channel.sendMessage(getEmbed(guild, requester).setAuthor("Fehler aufgetreten", null, bot.getJda().getSelfUser().getEffectiveAvatarUrl()).addField("Fehlermeldung", "`" + exception.getMessage() + "`", false).build()).queue();
}
});
}
use of com.sedmelluq.discord.lavaplayer.track.AudioTrack in project MantaroBot by Mantaro.
the class AudioRequester method playlistLoaded.
@Override
public void playlistLoaded(AudioPlaylist playlist) {
if (playlist.isSearchResult()) {
if (!skipSelection)
onSearchResult(playlist);
else
loadSingle(playlist.getTracks().get(0), false);
return;
}
int i = 0;
for (AudioTrack track : playlist.getTracks()) {
if (MantaroData.db().getGuild(event.getGuild()).getData().getMusicQueueSizeLimit() != null) {
if (i < MantaroData.db().getGuild(event.getGuild()).getData().getMusicQueueSizeLimit()) {
loadSingle(track, true);
} else {
event.getChannel().sendMessage(String.format(":warning: The queue you added had more than %d songs, so we added songs until this limit and ignored the rest.", MantaroData.db().getGuild(event.getGuild()).getData().getMusicQueueSizeLimit())).queue();
break;
}
} else {
if (i < MAX_QUEUE_LENGTH) {
loadSingle(track, true);
} else {
event.getChannel().sendMessage(":warning: The queue you added had more than 300 songs, so we added songs until this limit and ignored the rest.").queue();
break;
}
}
i++;
}
event.getChannel().sendMessage(String.format("Added **%d songs** to queue on playlist: **%s** *(%s)*", i, playlist.getName(), Utils.getDurationMinutes(playlist.getTracks().stream().mapToLong(temp -> temp.getInfo().length).sum()))).queue();
}
Aggregations