{"size": 1836, "ext": "js", "max_stars_repo_path": "commands/OSRS_Accounts/clues.js", "max_stars_repo_name": "FearrMe/oldschoolbot", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "commands/OSRS_Accounts/clues.js", "max_issues_repo_name": "FearrMe/oldschoolbot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "commands/OSRS_Accounts/clues.js", "max_forks_repo_name": "FearrMe/oldschoolbot", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.6551724138, "max_line_length": 90, "alphanum_fraction": 0.6377995643}
const { Command } = require('klasa');
const osrs = require('osrs-wrapper');
const { MessageEmbed } = require('discord.js');

module.exports = class extends Command {

	constructor(...args) {
		super(...args, {
			cooldown: 2,
			description: 'Shows the Clue Highscores of an account.',
			usage: '[user:user|username:str]',
			requiredPermissions: ['EMBED_LINKS']
		});
	}

	async run(msg, [username]) {
		username = this.getUsername(username, msg);

		const { Minigames } = await osrs.hiscores
			.getPlayer(username, 'Normal')
			.then(player => player)
			.catch(() => { throw this.client.notFound; });

		const clues = {
			easy: Minigames.Clue_Scrolls_Easy,
			medium: Minigames.Clue_Scrolls_Medium,
			hard: Minigames.Clue_Scrolls_Hard,
			elite: Minigames.Clue_Scrolls_Elite,
			master: Minigames.Clue_Scrolls_Master,
			overall: Minigames.Clue_Scrolls_All
		};

		for (const prop in clues) {
			clues[prop].rank = clues[prop].rank !== -1 ?
				clues[prop].rank.toLocaleString() : 0;

			clues[prop].score = clues[prop].score !== -1 ?
				clues[prop].score.toLocaleString() : 0;
		}

		const { easy, medium, hard, elite, master, overall } = clues;

		const embed = new MessageEmbed()
			.setAuthor(username)
			.setColor(52224)
			.setThumbnail('https://i.imgur.com/azW3cSB.png')
			.addField('Easy', `**Rank:** ${easy.rank}\n**Score:** ${easy.score}\n`, true)
			.addField('Medium', `**Rank:** ${medium.rank}\n**Score:** ${medium.score}\n`, true)
			.addField('Hard', `**Rank:** ${hard.rank}\n**Score:** ${hard.score}\n`, true)
			.addField('Elite', `**Rank:** ${elite.rank}\n**Score:** ${elite.score}\n`, true)
			.addField('Master', `**Rank:** ${master.rank}\n**Score:** ${master.score}\n`, true)
			.addField('Overall', `**Rank:** ${overall.rank}\n**Score:** ${overall.score}\n`, true);

		return msg.send({ embed });
	}

};
