Changed ping a little

This commit is contained in:
loicbersier 2018-10-09 16:31:23 +02:00
parent 1c165ed28b
commit 5a750c9951
2 changed files with 36 additions and 1 deletions

34
commands/utility/ping.js Normal file
View file

@ -0,0 +1,34 @@
const { oneLine } = require('common-tags');
const { Command } = require('discord.js-commando');
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.say('Pinging...');
return pingMsg.edit(oneLine`
${msg.channel.type !== 'dm' ? `${msg.author},` : ''}
<:ping:499226870047571978> Pong! The message round-trip took **${pingMsg.createdTimestamp - msg.createdTimestamp}**ms.
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
`);
} else {
await msg.edit('Pinging...');
return msg.edit(oneLine`
Pong! The message round-trip took **${msg.editedTimestamp - msg.createdTimestamp}**ms.
${this.client.ping ? `The heartbeat ping is **${Math.round(this.client.ping)}**ms.` : ''}
`);
}
}
};

View file

@ -25,7 +25,8 @@ client.registry
]) ])
.registerDefaultGroups() .registerDefaultGroups()
.registerDefaultCommands({ .registerDefaultCommands({
help: false help: false,
ping: false
}) })
.registerCommandsIn(path.join(__dirname, 'commands')); .registerCommandsIn(path.join(__dirname, 'commands'));
// Ready messages // Ready messages