const { oneLine } = require('common-tags');
const Command = require('../base');

module.exports = class PingCommand extends Command {
	constructor(client) {
		super(client, {
			name: 'ping',
			group: 'util',
			memberName: 'ping',
			description: 'Checks the bot\'s ping to the Discord server.',
			throttling: {
				usages: 5,
				duration: 10
			}
		});
	}

	async run(msg) {
		if(!msg.editable) {
			const pingMsg = await msg.reply('Pinging...');
			return pingMsg.edit(oneLine`
				${msg.channel.type !== 'dm' ? `${msg.author},` : ''}
				Pong! The message round-trip took ${pingMsg.createdTimestamp - msg.createdTimestamp}ms.
				${this.client.ws.ping ? `The heartbeat ping is ${Math.round(this.client.ws.ping)}ms.` : ''}
			`);
		} else {
			await msg.edit('Pinging...');
			return msg.edit(oneLine`
				Pong! The message round-trip took ${msg.editedTimestamp - msg.createdTimestamp}ms.
				${this.client.ws.ping ? `The heartbeat ping is ${Math.round(this.client.ws.ping)}ms.` : ''}
			`);
		}
	}
};

@@ -377,31 +377,8 @@
 ) %7B%0A
-%09%09if(!msg.editable) %7B%0A%09
 %09%09co
@@ -420,25 +420,24 @@
 ing...');%0A%09%09
-%09
 return pingM
@@ -453,17 +453,16 @@
 neLine%60%0A
-%09
 %09%09%09$%7Bmsg
@@ -508,25 +508,24 @@
 ,%60 : ''%7D%0A%09%09%09
-%09
 Pong! The me
@@ -548,24 +548,30 @@
  took $%7B
+%0A%09%09%09%09(
 pingMsg.
 createdT
@@ -562,20 +562,19 @@
 pingMsg.
-crea
+edi
 tedTimes
@@ -570,35 +570,40 @@
 editedTimestamp 
-- m
+%7C%7C pingM
 sg.createdTimest
@@ -609,228 +609,13 @@
 tamp
-%7Dms.%0A%09%09%09%09$%7Bthis.client.ws.ping ? %60The heartbeat ping is $%7BMath.round(this.client.ws.ping)%7Dms.%60 : ''%7D%0A%09%09%09%60);%0A%09%09%7D else %7B%0A%09%09%09await msg.edit('Pinging...');%0A%09%09%09return msg.edit(oneLine%60%0A%09%09%09%09Pong! The message round-trip took $%7B
+) - (
 msg.
@@ -630,17 +630,18 @@
 mestamp 
--
+%7C%7C
  msg.cre
@@ -657,14 +657,18 @@
 tamp
+)%0A%09%09%09
 %7Dms.%0A
-%09
 %09%09%09$
@@ -764,17 +764,12 @@
 %7D%0A%09%09
-%09
 %60);%0A
-%09%09%7D%0A
 %09%7D%0A%7D

Make ping command editing-aware and remove selfbot functionality from it