diff options
author | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-07 13:16:46 -0600 |
---|---|---|
committer | TymanWasTaken <32660892+tymanwastaken@users.noreply.github.com> | 2021-05-07 13:16:46 -0600 |
commit | d4d5d0e822c9570a2ca9ef86cc21073dbbec2087 (patch) | |
tree | 417c66368a79820b0ac2f36cd051e71b22b96f87 /src/commands/info/PingCommand.ts | |
parent | 6c0cfa0857e98889dcc676364f66e184e0250098 (diff) | |
download | tanzanite-d4d5d0e822c9570a2ca9ef86cc21073dbbec2087.tar.gz tanzanite-d4d5d0e822c9570a2ca9ef86cc21073dbbec2087.tar.bz2 tanzanite-d4d5d0e822c9570a2ca9ef86cc21073dbbec2087.zip |
slash commands working and added execSlash to ping command
Diffstat (limited to 'src/commands/info/PingCommand.ts')
-rw-r--r-- | src/commands/info/PingCommand.ts | 29 |
1 files changed, 29 insertions, 0 deletions
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<void> { + 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 + ] + }); + } } |