{"size": 1648, "ext": "js", "max_stars_repo_path": "commands/queue.js", "max_stars_repo_name": "Bri-ish/MTPA", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/queue.js", "max_issues_repo_name": "Bri-ish/MTPA", "max_issues_repo_issues_event_min_datetime": "2020-11-11T00:21:35.000Z", "max_issues_repo_issues_event_max_datetime": "2021-04-05T19:09:39.000Z", "max_forks_repo_path": "commands/queue.js", "max_forks_repo_name": "Bri-ish/MTPA", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 43.3684210526, "max_line_length": 149, "alphanum_fraction": 0.6589805825}
const Command = require('../modules/base/command');
const { embed } = require('../modules/utils');
const musicHandler = new (require('../modules/musicHandler'))();
const hastebin = require('hastebin-gen'); // Will replace in future
const { UserError } = require('../modules/base/error');

class Queue extends Command {
	constructor(client) {
		super(client);
		this.name = 'Queue';
		this.aliases = ['q', 'songs'];
		this.category = 'Music';
		this.description = 'Returns the music queue.';
		this.usage = '**queue**';
	}

	async run(client, message, args) {
		if (args.length !== 0) throw new UserError(`Invalid Usage - Correct Usage: ${this.usage}`); // Enforces correct usage
		let queue = musicHandler.getQueue(client, message); // Get guild relevent queue stuff
		let embedMsg = embed(message, 'Queue');
		if (queue.songs.length > 0) {
			embedMsg.addField('Now Playing', queue.songs[0].title, false);
			embedMsg.setThumbnail(queue.songs[0].thumbnail);
			if (queue.songs.length > 1) {
				let formatted = queue.songs.filter((song, index) => index != 0).map((song, index) => `${index + 1}. ${song.title}`).
join('\n');
				if (formatted.length <= 1024) embedMsg.addField('Music Queue', formatted, false); // Adds filter formatted queue with numbering
				else {
					let id = await hastebin(formatted);
					embedMsg.addField('Music Queue', id, false) // Adds hastebin url to embed
				}
			}
		} else embedMsg.addField('Music Queue', 'Queue is empty, use the play command to add something to the queue.', false); // Adds that queue is empty
		message.channel.send(embedMsg);
	}
}

module.exports = Queue;