/* * Copyright (C) 2022 jimj316 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package moe.nekojimi.chords.commands; import java.util.List; import java.util.Queue; import moe.nekojimi.chords.Chords; import moe.nekojimi.chords.Track; import moe.nekojimi.chords.TrackRequest; public class QueueCommand extends Command { public QueueCommand(Chords bot) { super(bot, "queue"); } @Override public void call(Invocation invocation) { String message = ">>> "; int i = 1; Track currentTrack = null; if (bot.getMusicHandler() != null) currentTrack = bot.getMusicHandler().getCurrentTrack(); if (currentTrack != null) message += ":notes: **Now playing: " + currentTrack + "**\n"; else message += ":mute: **Not playing anything right now.**\n"; final Queue trackQueue = bot.getQueueManager().getJukeboxQueue(); if (!trackQueue.isEmpty()) { message += "__Ready to play:__\n"; for (Track track : trackQueue) { message += ":bread: **" + i + ":** " + track + "\n"; i++; } } final List downloading = bot.getDownloader().getDownloadingTracks(); if (!downloading.isEmpty()) { message += "__Downloading:__\n"; for (TrackRequest request : downloading) { message += ":satellite: **" + (i) + ":** " + request + "\n"; i++; } } final List downloadQueue = bot.getDownloader().getDownloadQueue(); if (!downloadQueue.isEmpty()) { message += "__In queue for download:__\n"; for (TrackRequest request : downloadQueue) { message += ":inbox_tray: **" + (i) + ":** " + request + "\n"; i++; } } if (downloading.isEmpty() && trackQueue.isEmpty() && downloadQueue.isEmpty()) message += ":mailbox_with_no_mail: The track queue is empty."; // :inbox_tray: invocation.respond(message); } }