const left = (string, length, spacing = " ") => {
	string = string.toString();
	if(string.length >= length) return string;
	else return string + spacing.repeat(length - string.length);
};

module.exports = {
	process: async message => {
		const { results: info } = await process.output({
			type: "all_shards",
			input: () => ({
				id: cluster.worker.id,
				guilds: bot.guilds.size,
				memoryUsed: process.memoryUsage().heapUsed,
				streams: Array.from(bot.players.values()).filter(player => player.connection).length,
				shards: cluster.worker.shardRange.substring(7),
				uptime: Date.now() - bot.startTime
			})
		});

		const maxLen = {};
		const totalWorkers = info.length;
		maxLen.id = totalWorkers.toString().length;

		const totalGuilds = info.reduce((a, b) => a + b.guilds, 0);
		maxLen.guilds = totalGuilds.toString().length;

		const totalMemory = (info.reduce((a, b) => a + b.memoryUsed, 0) / Math.pow(1024, 3)).toFixed(2);
		maxLen.memory = Math.max(
			totalMemory.length,
			...info.map(data => (data.memoryUsed / Math.pow(1024, 3)).toFixed(2).length)
		);

		const totalStreams = info.reduce((a, b) => a + b.streams, 0);
		maxLen.streams = totalStreams.toString().length;

		const totalShards = bot.totalShards;
		maxLen.shards = Math.max(...info.map(data => data.shards.length));

		const totalUptime = bot.utils.secondsToDuration(info.reduce((a, b) => a + b.uptime, 0) / 1000);
		maxLen.uptime = totalUptime.length;

		const workerInfo = [];
		info.forEach(data => {
			let line = "";
			let isCurrent = cluster.worker.id === data.id ? "*" : "";
			line += left(isCurrent, 2).reverse();
			line += left(data.id, maxLen.id);
			line += ": GUILD ";
			line += left(data.guilds, maxLen.guilds);
			line += ", STREAM ";
			line += left(data.streams, maxLen.streams);
			line += ", SHARD ";
			line += left(data.shards, maxLen.shards);
			line += ", RAM ";
			line += left((data.memoryUsed / Math.pow(1024, 3)).toFixed(2), maxLen.memory);
			line += "GB, UP ";
			line += left(bot.utils.secondsToDuration(data.uptime / 1000), maxLen.uptime);

			workerInfo.push(line);
		});
		workerInfo.push(`  T: GUILD ${totalGuilds}, STREAM ${totalStreams}, SHARD ${left(totalShards, maxLen.shards)}, ` +
			`RAM ${left(totalMemory, maxLen.memory)}GB, UP ${totalUptime}`);

		return bot.utils.codeBlock(workerInfo.join("\n"), "prolog");
	},
	description: "Get info about each worker that hosts a bot"
};

@@ -132,17 +132,8 @@
 turn
- string +
  spa
@@ -167,16 +167,25 @@
 .length)
+ + string
 ;%0A%7D;%0A%0Amo
@@ -1511,21 +1511,13 @@
 %09%09%09l
-et isCurrent 
+ine +
 = cl
@@ -1552,55 +1552,17 @@
 ? %22*
+ 
 %22 : %22
-%22;%0A%09%09%09line += left(isCurrent, 2).reverse()
+  %22
 ;%0A%09%09

fix isCurrent left