diff --git a/src/main/java/moe/nekojimi/chords/Main.java b/src/main/java/moe/nekojimi/chords/Main.java index 1ecbfbf..98b8289 100644 --- a/src/main/java/moe/nekojimi/chords/Main.java +++ b/src/main/java/moe/nekojimi/chords/Main.java @@ -33,7 +33,7 @@ import net.dv8tion.jda.api.utils.cache.CacheFlag; public class Main extends ListenerAdapter { - private static final double SEARCH_SCORE_THRESHOLD_AUTOPLAY = 0.9; + private static final double SEARCH_SCORE_THRESHOLD_AUTOPLAY = 9999; // disable autoplay it sucks private static final double SEARCH_SCORE_THRESHOLD_DISPLAY = 0.6; private MusicHandler musicHandler; @@ -83,15 +83,15 @@ public class Main extends ListenerAdapter downloader.setMessageHandler((Song song, Exception ex) -> { TextChannel channel = jda.getTextChannelById(song.getRequestedIn()); - String bracketNo = "[" + song.getNumber() + "] "; +// String bracketNo = "[" + song.getNumber() + "] "; if (channel != null) if (ex == null) if (song.getLocation() != null) - channel.sendMessage(bracketNo + "Finished downloading " + song + " for " + song.getRequestedBy() + ", added to queue!").queue(); + channel.sendMessage(/*bracketNo + */"Finished downloading " + song + " for " + song.getRequestedBy() + ", added to queue!").queue(); else - channel.sendMessage(bracketNo + "Now downloading " + song + " for " + song.getRequestedBy() + " ...").queue(); + channel.sendMessage(/*bracketNo + */"Now downloading " + song + " for " + song.getRequestedBy() + " ...").queue(); else - channel.sendMessage(bracketNo + "Failed to download " + song + " for " + song.getRequestedBy() + "! Reason: " + ex.getMessage()).queue(); + channel.sendMessage(/*bracketNo + */"Failed to download " + song + " for " + song.getRequestedBy() + "! Reason: " + ex.getMessage()).queue(); }); searcher = MetaSearcher.loadYAML(new File("searchproviders.yml")); @@ -220,7 +220,7 @@ public class Main extends ListenerAdapter if (index >= 1 && index <= size) { Result res = lastSearchResults.get(index - 1); - queueDownload(res.getLink(), event); + queueDownload(res, event); // event.getChannel().sendMessage("Song removed.").queue(); } else if (size > 1) event.getChannel().sendMessage("That's not a number between 1 and " + size + "!").queue(); @@ -282,7 +282,7 @@ public class Main extends ListenerAdapter } } - private void queueDownload(final URL url, GuildMessageReceivedEvent event) + private Song queueDownload(final URL url, GuildMessageReceivedEvent event) { Song song = new Song(url); song.setRequestedBy(event.getAuthor().getName()); @@ -290,6 +290,16 @@ public class Main extends ListenerAdapter song.setNumber(trackNumber); trackNumber++; downloader.accept(song); + return song; + } + + private Song queueDownload(Result res, GuildMessageReceivedEvent event) + { + Song song = queueDownload(res.getLink(), event); + song.setArtist(res.getArtist()); + song.setTitle(res.getTitle()); + song.setNumber(trackNumber); + return song; } private void onRestartCommand(GuildMessageReceivedEvent event)