From d4d5d0e822c9570a2ca9ef86cc21073dbbec2087 Mon Sep 17 00:00:00 2001 From: TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> Date: Fri, 7 May 2021 13:16:46 -0600 Subject: slash commands working and added execSlash to ping command --- src/commands/info/PingCommand.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/commands/info/PingCommand.ts') diff --git a/src/commands/info/PingCommand.ts b/src/commands/info/PingCommand.ts index 5a5b819..bb3324d 100644 --- a/src/commands/info/PingCommand.ts +++ b/src/commands/info/PingCommand.ts @@ -1,3 +1,5 @@ +import { CommandInteraction } from 'discord.js'; +import { Message } from 'discord.js'; import { MessageEmbed } from 'discord.js'; import { BotCommand } from '../../lib/extensions/BotCommand'; import { BotMessage } from '../../lib/extensions/BotMessage'; @@ -39,4 +41,31 @@ export default class PingCommand extends BotCommand { embed }); } + + public async execSlash(message: CommandInteraction): Promise { + const timestamp1 = message.createdTimestamp; + await message.reply('Pong!'); + const timestamp2 = await message.fetchReply().then(m => (m as Message).createdTimestamp) + const botLatency = `\`\`\`\n ${Math.floor( + timestamp2 - timestamp1 + )}ms \`\`\``; + const apiLatency = `\`\`\`\n ${Math.round( + this.client.ws.ping + )}ms \`\`\``; + const embed = new MessageEmbed() + .setTitle('Pong! 🏓') + .addField('Bot Latency', botLatency, true) + .addField('API Latency', apiLatency, true) + .setFooter( + message.user.username, + message.user.displayAvatarURL({ dynamic: true }) + ) + .setTimestamp(); + await message.editReply({ + content: null, + embeds: [ + embed + ] + }); + } } -- cgit