2018-10-09 16:31:23 +02:00
|
|
|
const { oneLine } = require('common-tags');
|
|
|
|
const { Command } = require('discord.js-commando');
|
2018-11-28 01:35:26 +01:00
|
|
|
const SelfReloadJSON = require('self-reload-json');
|
|
|
|
const blacklist = require('../../blacklist');
|
2018-10-09 16:31:23 +02:00
|
|
|
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
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-11-28 01:35:26 +01:00
|
|
|
async run(message) {
|
|
|
|
let blacklistJson = new SelfReloadJSON('json/blacklist.json');
|
|
|
|
if(blacklistJson[message.author.id])
|
|
|
|
return blacklist(blacklistJson[message.author.id] , message)
|
|
|
|
|
|
|
|
if(!message.editable) {
|
|
|
|
const pingMsg = await message.say('Pinging...');
|
2018-10-09 16:31:23 +02:00
|
|
|
return pingMsg.edit(oneLine`
|
2018-11-28 01:35:26 +01:00
|
|
|
${message.channel.type !== 'dm' ? `${message.author},` : ''}
|
|
|
|
<:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - message.createdTimestamp}**ms.
|
2018-10-09 16:31:23 +02:00
|
|
|
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
|
|
|
|
`);
|
|
|
|
} else {
|
2018-11-28 01:35:26 +01:00
|
|
|
await message.edit('Pinging...');
|
|
|
|
return message.edit(oneLine`
|
|
|
|
Pong! The message round-trip took **${message.editedTimestamp - message.createdTimestamp}**ms.
|
2018-10-09 16:31:23 +02:00
|
|
|
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
|
|
|
|
`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|