<commit_before>'use babel';
'use strict';

import Command from '../Command';
import now from 'performance-now';

export default class Reload extends Command
{
	constructor(bot)
	{
		super(bot, {
			name: 'reload',
			description: 'Reload a command or all commands',
			aliases: ['r'],
			usage: '<prefix>reload [command]',
			extraHelp: `If a command name or alias is provided the specific command will be reloaded. Otherwise, all commands will be reloaded.`,
			group: 'base',
			permissions: ['ADMINISTRATOR']
		});
	}

	async action(message, args, mentions) // eslint-disable-line no-unused-vars
	{
		let start = now();
		if (args[0]) this.bot.commandLoader.reloadCommand(args[0]);
		else this.bot.commandLoader.loadCommands();
		let end = now();
		let name = args[0] ? this.bot.commands.findByNameOrAlias(args[0]).name : null;
		let text = name ? ` "${name}"` : 's';
		message.channel.sendMessage(`Command${text} reloaded. (${(end - start).toFixed(3)} ms)`)<commit_msg>Add fail on invalid command to reload<commit_after>'use babel';
'use strict';

import Command from '../Command';
import now from 'performance-now';

export default class Reload extends Command
{
	constructor(bot)
	{
		super(bot, {
			name: 'reload',
			description: 'Reload a command or all commands',
			aliases: ['r'],
			usage: '<prefix>reload [command]',
			extraHelp: `If a command name or alias is provided the specific command will be reloaded. Otherwise, all commands will be reloaded.`,
			group: 'base',
			permissions: ['ADMINISTRATOR']
		});
	}

	async action(message, args, mentions) // eslint-disable-line no-unused-vars
	{
		let start = now();
		let command = this.bot.commands.findByNameOrAlias(args[0]);
		if (args[0] && !command)
		{
			message.channel.sendMessage(`Command "${args[0]}" could not be found.`)
				.then(response =>
				{
					response.delete(5 * 1000);
				});
			return;
		}
		if (command) this.bot.commandLoader.reloadCommand(command.name);
		else this.bot.commandLoader.loadCommands();
		let end = now();
		let name = args[0] ? this.bot.commands.findByNameOrAlias(args[0]).name : null;
		let text = name ? ` "${name}"` : 's';
		message.channel.sendMessage(`Command${text} reloaded. (${(end - start).toFixed(3)} ms)`)
{'fraction_non_alphanumeric': 0.15678346810422283, 'fraction_numerical': 0.0071877807726864335, 'mean_word_length': 4.143187066974596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2989511', 'n_tokens_mistral': 786, 'n_tokens_neox': 714, 'n_words': 203}