Skip to content

Commit

Permalink
Fix the queue not placing you on the correct page
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberedCake committed Feb 4, 2024
1 parent d7dc074 commit 67ac249
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public QueueCMD() {
private int currentTrackIndex;

public int getPageOf(int position) {
return (int) ((double)(position + ITEMS_PER_PAGE) / (double)ITEMS_PER_PAGE);
return (int) Math.floor((double) (position + (ITEMS_PER_PAGE - 1)) / ITEMS_PER_PAGE);
// simple algebra
// \operatorname{floor}\left(\frac{v+6}{6}\right)
// \operatorname{floor}\left(\frac{v+5}{6}\right)
// ^ paste into desmos
// originated from the equation below: \left(i\cdot6\right)-6=p_{g} (where i is the index, like 7, and p_g is the page number)
}
Expand All @@ -65,7 +65,7 @@ private void handleQueueCMD(IReplyCallback callback, int page) {
if (musicPlayer == null) return;

this.currentTrackIndex = musicPlayer.getTrackScheduler().getQueue().getCurrentIndex();
if (page == -1)
if (page != -1)
page = getPageOf(currentTrackIndex);

int maxPages = getMaxPages(callback.getGuild());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public LoadDev() {
@Override
public void command(SlashCommandInteractionEvent event) {
try {
Command.getCommandClass(Play.class).handlePlay(event, "https://www.youtube.com/watch?v=X-nwU7fvUp4&list=PLQFF4PlpFPWUOAUyHHYrcI6PgP_5LBU19&index=1&pp=gAQBiAQB8AUB", false, true);
Command.getCommandClass(Play.class).handlePlay(event, "https://music.youtube.com/playlist?list=PLQFF4PlpFPWVkThOxHDoyyrsuzTuzwwW9", false, true);
} catch (Exception exception) {
Embeds.throwError(event, event.getUser(), "Error:" + exception.getMessage(), true, null);
}
Expand Down

0 comments on commit 67ac249

Please sign in to comment.