From 7b5df4ca0a5bd6fcf033ef40563599593b156910 Mon Sep 17 00:00:00 2001 From: Minteck Date: Wed, 13 Jul 2022 23:34:21 +0200 Subject: Initial commit --- commands/ping.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 commands/ping.ts (limited to 'commands/ping.ts') diff --git a/commands/ping.ts b/commands/ping.ts new file mode 100644 index 0000000..5b79231 --- /dev/null +++ b/commands/ping.ts @@ -0,0 +1,33 @@ +import {CommandBase} from "../core/CommandBase"; +import {MessageEmbed} from "discord.js"; +import {SlashCommandBuilder} from "@discordjs/builders"; +import {CommandAction} from "../core/CommandAction"; + +export class PingCommand extends CommandBase { + constructor() { + super(); + this.slashCommandData = new SlashCommandBuilder() + .setName("ping") + .setDescription("Shows the latency between the bot and Discord") + } + + public handle(action: CommandAction) { + let interaction = action.getInteraction(); + let VoiceBase = global.VoiceBase; + let processing = new Date().getTime() - global.processingStart; + let interactionTime = new Date().getTime() - interaction.createdAt.getTime(); + let apiTime = global.client.ws.ping; + + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle(":rocket: Pong!") + .addFields( + {name: "Processing", value: processing.toFixed(2) + "ms", inline: true}, + {name: "Interaction", value: interactionTime.toFixed(2) + "ms", inline: true}, + {name: "API", value: apiTime.toFixed(2) + "ms", inline: true} + ) + ] + }); + } +} \ No newline at end of file -- cgit