UNPKG

supabotbase

Version:

An easy-to-use Discord.js Bot base with messages and interactions support.

41 lines (31 loc) • 1.02 kB
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 }; } }