0

Added clickable link to original track sources.

This commit is contained in:
Logan Fick
2019-05-26 16:47:53 -04:00
parent 67d2b3ad50
commit f82dbb58f6
7 changed files with 31 additions and 28 deletions

View File

@@ -85,7 +85,7 @@ public final class TrackLoadHandler implements AudioLoadResultHandler {
scheduler.addToQueue(track, requester);
response = new CommandResponse("notes",
this.requester.getAsMention() + " added the following track to the queue:");
response.attachEmbed(TrackUtil.generateTrackInfoEmbed(track));
response.attachEmbed(TrackUtil.trackInfoEmbed(track));
response.sendResponse(this.channel);
}
@@ -126,7 +126,7 @@ public final class TrackLoadHandler implements AudioLoadResultHandler {
scheduler.addToQueue(track, this.requester);
response = new CommandResponse("notes",
this.requester.getAsMention() + " added the following track to the queue:");
response.attachEmbed(TrackUtil.generateTrackInfoEmbed(track));
response.attachEmbed(TrackUtil.trackInfoEmbed(track));
response.sendResponse(this.channel);
} else {
response = new CommandResponse("no_entry_sign", "Sorry " + this.requester.getAsMention()
@@ -158,7 +158,7 @@ public final class TrackLoadHandler implements AudioLoadResultHandler {
response = new CommandResponse("notes",
this.requester.getAsMention() + " added the following tracks to the queue:");
response.attachEmbed(TrackUtil.generateTrackListInfoEmbed(addedTracks, false));
response.attachEmbed(TrackUtil.trackListInfoEmbed(addedTracks, false));
response.sendResponse(this.channel);
} else {
response = new CommandResponse("no_entry_sign",

View File

@@ -50,7 +50,7 @@ public final class ForceSkip implements Command {
AudioUtil.getTrackScheduler(guild).skipCurrentTrack();
final CommandResponse response = new CommandResponse("gun",
executor.getAsMention() + " force skipped the following track:");
response.attachEmbed(TrackUtil.generateTrackInfoEmbed(skippedTrack));
response.attachEmbed(TrackUtil.trackInfoEmbed(skippedTrack));
return response;
}
}

View File

@@ -32,7 +32,7 @@ public final class NowPlaying implements Command {
final CommandResponse response = new CommandResponse("dancer",
executor.getAsMention() + ", this is the track currently playing:");
response.attachEmbed(TrackUtil.generateCurrentTrackInfoEmbed(guild));
response.attachEmbed(TrackUtil.currentTrackInfoEmbed(guild));
return response;
}
}

View File

@@ -70,7 +70,7 @@ public final class Queue implements Command {
response.setReactionCallbackTarget(executor);
response.setReactionCallbackExpireDelay(3, TimeUnit.SECONDS);
response.attachEmbed(TrackUtil.generatePaginatedTrackListInfoEmbed(queue, page));
response.attachEmbed(TrackUtil.pagedTrackListInfoEmbed(queue, page));
return response;
}
}

View File

@@ -59,7 +59,7 @@ public final class Remove implements Command {
final CommandResponse response = new CommandResponse("question",
executor.getAsMention() + ", which track would you like to remove from the top of the queue?");
response.attachEmbed(TrackUtil.generateTrackListInfoEmbed(scheduler.getQueue(), true));
response.attachEmbed(TrackUtil.trackListInfoEmbed(scheduler.getQueue(), true));
for (int i = 0; i < scheduler.getQueue().size(); i++) {
final int trackNumber = i + 1;
@@ -94,7 +94,7 @@ public final class Remove implements Command {
scheduler.removeFromQueue(index - 1);
final CommandResponse response = new CommandResponse("scissors",
executor.getAsMention() + " removed the following track from the queue:");
response.attachEmbed(TrackUtil.generateTrackInfoEmbed(removedTrack));
response.attachEmbed(TrackUtil.trackInfoEmbed(removedTrack));
return response;
} catch (final IndexOutOfBoundsException exception) {
return new CommandResponse("no_entry_sign",

View File

@@ -58,7 +58,7 @@ public final class Skip implements Command {
AudioUtil.getTrackScheduler(guild).skipCurrentTrack();
final CommandResponse response = new CommandResponse("gun",
executor.getAsMention() + " was the last required vote. The following track has been skipped:");
response.attachEmbed(TrackUtil.generateTrackInfoEmbed(skippedTrack));
response.attachEmbed(TrackUtil.trackInfoEmbed(skippedTrack));
return response;
} else {
if (SkipTracker.getRemainingRequired(guild) == 1) {

View File

@@ -17,6 +17,7 @@ package dev.logal.logalbot.utils;
import java.util.List;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import com.sedmelluq.discord.lavaplayer.track.AudioTrackInfo;
import net.dv8tion.jda.core.EmbedBuilder;
import net.dv8tion.jda.core.entities.Guild;
@@ -28,29 +29,30 @@ public final class TrackUtil {
// Static access only.
}
public static final MessageEmbed generateTrackInfoEmbed(final AudioTrack track) {
public static final MessageEmbed trackInfoEmbed(final AudioTrack track) {
Checks.notNull(track, "Track");
final EmbedBuilder builder = new EmbedBuilder();
builder.addField(StringUtil.sanitize(track.getInfo().title),
StringUtil.sanitize(track.getInfo().author) + " - " + StringUtil.formatTime(track.getDuration()),
false);
final AudioTrackInfo info = track.getInfo();
builder.addField(StringUtil.sanitize(info.title), StringUtil.sanitize(info.author) + " - "
+ StringUtil.formatTime(track.getDuration()) + " - [View](" + info.uri + ")", false).build();
return builder.build();
}
public static final MessageEmbed generateCurrentTrackInfoEmbed(final Guild guild) {
public static final MessageEmbed currentTrackInfoEmbed(final Guild guild) {
Checks.notNull(guild, "Guild");
final EmbedBuilder builder = new EmbedBuilder();
final AudioTrack track = AudioUtil.getLoadedTrack(guild);
builder.addField(
StringUtil.sanitize(track.getInfo().title), StringUtil.sanitize(track.getInfo().author) + " - "
+ StringUtil.formatTime(track.getPosition()) + "/" + StringUtil.formatTime(track.getDuration()),
false);
final AudioTrackInfo info = track.getInfo();
builder.addField(StringUtil.sanitize(info.title),
StringUtil.sanitize(info.author) + " - " + StringUtil.formatTime(track.getPosition()) + "/"
+ StringUtil.formatTime(track.getDuration()) + " - [View](" + info.uri + ")",
false).build();
return builder.build();
}
public static final MessageEmbed generateTrackListInfoEmbed(final List<AudioTrack> tracks, final boolean numbered) {
public static final MessageEmbed trackListInfoEmbed(final List<AudioTrack> tracks, final boolean numbered) {
Checks.notNull(tracks, "Tracks");
Checks.notNull(numbered, "Numbered");
@@ -61,14 +63,15 @@ public final class TrackUtil {
}
final AudioTrack track = tracks.get(i);
final AudioTrackInfo info = track.getInfo();
if (numbered) {
builder.addField("**" + (i + 1) + ":** " + StringUtil.sanitize(track.getInfo().title),
StringUtil.sanitize(track.getInfo().author) + " - "
+ StringUtil.formatTime(track.getDuration()),
builder.addField(
"**" + (i + 1) + ":** " + StringUtil.sanitize(info.title), StringUtil.sanitize(info.author)
+ " - " + StringUtil.formatTime(track.getDuration()) + " - [View](" + info.uri + ")",
false);
} else {
builder.addField(StringUtil.sanitize(track.getInfo().title), StringUtil.sanitize(track.getInfo().author)
+ " - " + StringUtil.formatTime(track.getDuration()), false);
builder.addField(StringUtil.sanitize(info.title), StringUtil.sanitize(info.author) + " - "
+ StringUtil.formatTime(track.getDuration()) + " - [View](" + info.uri + ")", false);
}
}
@@ -78,7 +81,7 @@ public final class TrackUtil {
return builder.build();
}
public static final MessageEmbed generatePaginatedTrackListInfoEmbed(final List<AudioTrack> tracks, int page) {
public static final MessageEmbed pagedTrackListInfoEmbed(final List<AudioTrack> tracks, int page) {
Checks.notNull(tracks, "Tracks");
Checks.notNull(page, "Page");
@@ -99,9 +102,9 @@ public final class TrackUtil {
for (int i = start; i < end && i < tracks.size(); i++) {
final AudioTrack track = tracks.get(i);
builder.addField("**" + (i + 1) + ":** " + StringUtil.sanitize(track.getInfo().title),
StringUtil.sanitize(track.getInfo().author) + " - " + StringUtil.formatTime(track.getDuration()),
false);
final AudioTrackInfo info = track.getInfo();
builder.addField("**" + (i + 1) + ":** " + StringUtil.sanitize(info.title), StringUtil.sanitize(info.author)
+ " - " + StringUtil.formatTime(track.getDuration()) + " - [View](" + info.uri + ")", false);
}
builder.setTitle("**" + tracks.size() + " Total Tracks - Page " + (page + 1) + "/" + pages + "**");