thaldrin/DiscordModules/General/ping.js

27 lines
849 B
JavaScript
Raw Normal View History

2019-10-09 16:19:30 +00:00
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);
2020-01-09 17:14:50 +00:00
return m.edit(`REST ${rest / 1000}s (${rest}ms)\nWS ${ws / 1000}s (${ws}ms)`);
2019-10-09 16:19:30 +00:00
}
2020-01-09 17:14:50 +00:00
}
// \nShard Avg. ${shard / 1000}s (${shard}ms) [${ctx.guild.shard.pings.join(', ')}]