Fix play command search result selection.

master
Nekojimi 3 months ago
parent 7d3795b10a
commit 95f838c392
  1. 16
      src/main/java/moe/nekojimi/chords/commands/PlayCommand.java

@ -35,7 +35,7 @@ public class PlayCommand extends Command
private static final double SEARCH_SCORE_THRESHOLD_DISPLAY = 0.6; private static final double SEARCH_SCORE_THRESHOLD_DISPLAY = 0.6;
private static final double SEARCH_SCORE_THRESHOLD_AUTOPLAY = 9999; // disable autoplay it sucks private static final double SEARCH_SCORE_THRESHOLD_AUTOPLAY = 9999; // disable autoplay it sucks
// private List<Result> lastSearchResults; private List<Result> lastSearchResults;
public PlayCommand(Chords main) public PlayCommand(Chords main)
{ {
@ -56,15 +56,15 @@ public class PlayCommand extends Command
} catch (MalformedURLException mux) } catch (MalformedURLException mux)
{ {
// not a URL, try parsing it as a search result // not a URL, try parsing it as a search result
if (request.getSearchResults() != null && !request.getSearchResults().isEmpty()) if (lastSearchResults != null && !lastSearchResults.isEmpty())
{ {
try try
{ {
int index = Integer.parseInt(invocation.getArgs().get(0)); int index = Integer.parseInt(invocation.getArgs().get(0));
int size = request.getSearchResults().size(); int size = lastSearchResults.size();
if (index >= 1 && index <= size) if (index >= 1 && index <= size)
{ {
Result result = request.getSearchResults().get(index - 1); Result result = lastSearchResults.get(index - 1);
request.setResult(result); request.setResult(result);
bot.queueDownload(request); bot.queueDownload(request);
// event.getChannel().sendMessage("Track removed.").queue(); // event.getChannel().sendMessage("Track removed.").queue();
@ -91,8 +91,7 @@ public class PlayCommand extends Command
return; return;
} }
request.setSearchResults(results); lastSearchResults = results;
// lastSearchResults = results;
if (results.isEmpty()) if (results.isEmpty())
{ {
@ -130,4 +129,9 @@ public class PlayCommand extends Command
} }
} }
@Override
public String argumentDescription()
{
return "<URL / Search>";
}
} }

Loading…
Cancel
Save