supabotbase
Version:
An easy-to-use Discord.js Bot base with messages and interactions support.
41 lines (31 loc) ⢠1.02 kB
JavaScript
const CommandConstructor = require(`../../`).CommandConstructor;
module.exports = class Ping extends CommandConstructor {
constructor() {
super();
this.setHelp({
name: "ping",
description: "Test my ping"
});
this.setAliases("p", "pingpong");
this.setSlashCommandsEnabled(true);
this.setSlashCommandType("hidden");
}
async onExecute(message) {
if (message.isSlashCommand) {
if (this.last) message.answerCommand(`**Last ping**\nš ${this.last.ping}ms\nš ${this.last.ws}ms`)
else message.answerCommand(`Pong! Use \`${message.prefix}ping\` to calculate my ping!`);
return;
}
let start = Date.now();
let msg = await message.channel.send(message.embed().setDescription("š"));
let ping = Math.round(Date.now()-start-this.client.ws.ping);
let ws = Math.round(this.client.ws.ping);
msg.edit(message.embed()
.setDescription(`š ${ping}ms\nš ${ws}ms`)
);
this.last = {
ping,
ws
};
}
}