Disable autoplay, remove track number tag in download messages.

crossfading
Nekojimi 3 years ago committed by AwesomeToaster
parent 7c1000ba55
commit 3ee4f8fde5
  1. 24
      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 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 static final double SEARCH_SCORE_THRESHOLD_DISPLAY = 0.6;
private MusicHandler musicHandler; private MusicHandler musicHandler;
@ -83,15 +83,15 @@ public class Main extends ListenerAdapter
downloader.setMessageHandler((Song song, Exception ex) -> downloader.setMessageHandler((Song song, Exception ex) ->
{ {
TextChannel channel = jda.getTextChannelById(song.getRequestedIn()); TextChannel channel = jda.getTextChannelById(song.getRequestedIn());
String bracketNo = "[" + song.getNumber() + "] "; // String bracketNo = "[" + song.getNumber() + "] ";
if (channel != null) if (channel != null)
if (ex == null) if (ex == null)
if (song.getLocation() != 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 else
channel.sendMessage(bracketNo + "Now downloading " + song + " for " + song.getRequestedBy() + " ...").queue(); channel.sendMessage(/*bracketNo + */"Now downloading " + song + " for " + song.getRequestedBy() + " ...").queue();
else 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")); searcher = MetaSearcher.loadYAML(new File("searchproviders.yml"));
@ -220,7 +220,7 @@ public class Main extends ListenerAdapter
if (index >= 1 && index <= size) if (index >= 1 && index <= size)
{ {
Result res = lastSearchResults.get(index - 1); Result res = lastSearchResults.get(index - 1);
queueDownload(res.getLink(), event); queueDownload(res, event);
// event.getChannel().sendMessage("Song removed.").queue(); // event.getChannel().sendMessage("Song removed.").queue();
} else if (size > 1) } else if (size > 1)
event.getChannel().sendMessage("That's not a number between 1 and " + size + "!").queue(); 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 song = new Song(url);
song.setRequestedBy(event.getAuthor().getName()); song.setRequestedBy(event.getAuthor().getName());
@ -290,6 +290,16 @@ public class Main extends ListenerAdapter
song.setNumber(trackNumber); song.setNumber(trackNumber);
trackNumber++; trackNumber++;
downloader.accept(song); 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) private void onRestartCommand(GuildMessageReceivedEvent event)

Loading…
Cancel
Save