From 763fb7d98c3accbb21adf035a7cf0a83cb9533c9 Mon Sep 17 00:00:00 2001 From: TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> Date: Tue, 27 Apr 2021 21:06:22 -0600 Subject: legit just copy utilibot v2 code --- src/commands/info/PingCommand.ts | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/commands/info/PingCommand.ts (limited to 'src/commands/info/PingCommand.ts') diff --git a/src/commands/info/PingCommand.ts b/src/commands/info/PingCommand.ts new file mode 100644 index 0000000..5a5b819 --- /dev/null +++ b/src/commands/info/PingCommand.ts @@ -0,0 +1,42 @@ +import { MessageEmbed } from 'discord.js'; +import { BotCommand } from '../../lib/extensions/BotCommand'; +import { BotMessage } from '../../lib/extensions/BotMessage'; + +export default class PingCommand extends BotCommand { + constructor() { + super('ping', { + aliases: ['ping'], + description: { + content: 'Gets the latency of the bot', + usage: 'ping', + examples: ['ping'] + } + }); + } + + public async exec(message: BotMessage): Promise { + const sentMessage = await message.util.send('Pong!'); + const timestamp: number = message.editedTimestamp + ? message.editedTimestamp + : message.createdTimestamp; + const botLatency = `\`\`\`\n ${Math.floor( + sentMessage.createdTimestamp - timestamp + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round( + message.client.ws.ping + )}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.author.username, + message.author.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await sentMessage.edit({ + content: null, + embed + }); + } +} -- cgit