const { Command } = require('klasa');
const fs = require('fs-nextra');
const { resolve, join } = require('path');

module.exports = class extends Command {

	constructor(...args) {
		super(...args, {
			permLevel: 10,
			guarded: true,
			description: (msg) => msg.language.get('COMMAND_TRANSFER_DESCRIPTION'),
			usage: '<Piece:piece>'
		});
	}

	async run(msg, [piece]) {
		const file = piece.type === 'command' ? join(...piece.file) : piece.file;
		const fileLocation = resolve(this.client.coreBaseDir, `${piece.type}s`, file);
		await fs.access(fileLocation).catch(() => { throw msg.language.get('COMMAND_TRANSFER_ERROR'); });
		return fs.copy(fileLocation, resolve(this.client.clientBaseDir, `${piece.type}s`, file))
			.then(() => {
				this.client[`${piece.type}s`].load(resolve(this.client.clientBaseDir, `${piece.type}s`), piece.file);
				return msg.sendMessage(msg.language.get('COMMAND_TRANSFER_SUCCESS', piece.type, piece.name));
			})
			.catch((err) => {
				this.client.emit('error', err.stack);
				return msg.sendMessage(msg.language.get('COMMAND_TRANSFER_FAILED', piece.type, piece.name));
			});
	}

};

@@ -630,24 +630,27 @@
 ;%0A%09%09
-return fs.copy(f
+try %7B%0A%09%09%09const newF
 ileL
@@ -656,17 +656,18 @@
 Location
-,
+ =
  resolve
@@ -714,127 +714,330 @@
 e%7Ds%60
-, file))%0A%09%09%09.then(() =%3E %7B%0A%09%09%09%09this.client%5B%60$%7Bpiece.type%7Ds%60%5D.load(resolve(this.client.clientBaseDir, %60$%7Bpiece.type%7Ds%60), 
+);%0A%09%09%09await fs.copy(fileLocation, join(newFileLocation, file));%0A%09%09%09this.client%5B%60$%7Bpiece.type%7Ds%60%5D.load(newFileLocation, piece.file);%0A%09%09%09if (this.client.sharded) %7B%0A%09%09%09%09await this.client.shard.broadcastEval(%60%0A%09%09%09%09%09if (this.shard.id !== $%7Bthis.client.shard.id%7D) this.$%7Bpiece.type%7Ds.load('$%7BnewFileLocation%7D', $%7BJSON.stringify(
 piec
@@ -1043,22 +1043,36 @@
 ce.file)
+%7D)
 ;%0A%09%09
+%09
+%09%60);%0A%09%09%09%7D%0A
 %09%09
+%09
 return m
@@ -1163,34 +1163,24 @@
 ;%0A%09%09
-%09%7D)%0A%09%09%09.
+%7D 
 catch
-(
+ 
 (err)
- =%3E
  %7B%0A
-%09
 %09%09%09t
@@ -1216,17 +1216,16 @@
 stack);%0A
-%09
 %09%09%09retur
@@ -1314,20 +1314,17 @@
 me));%0A%09%09
-%09%7D);
+%7D
 %0A%09%7D%0A%0A%7D;%0A

Make transfer shard friendly