thaldrin/DiscordModules/General/ping.js
2019-10-14 13:19:41 +02:00

25 lines
No EOL
844 B
JavaScript
Executable file

const Command = require('../../src/structures/Command');
module.exports = class Ping extends Command {
constructor() {
super({
name: 'ping',
description: 'Pings Discord to check the API and gateway latency.',
aliases: [],
module: 'General',
cooldown: 0,
guildOnly: false,
developerOnly: false
});
}
async command(ctx) {
const m = await ctx.send(`Pinging..`);
const rest = Math.round(m.createdTimestamp - ctx.msg.createdTimestamp);
const ws = Math.round(ctx.client.ws.ping);
const shard = Math.round(ctx.guild.shard.ping);
return m.edit(`REST ${rest / 1000}s (${rest}ms)\nWS ${ws / 1000}s (${ws}ms)\nShard Avg. ${shard / 1000}s (${shard}ms) [${ctx.guild.shard.pings.join(', ')}]`);
}
}