blob: 59b639359a17a727e206ab98a7677dd5ec105cee [file] [log] [blame]
pineafan63fc5e22022-08-04 22:04:10 +01001import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
pineafan4f164f32022-02-26 22:07:12 +00002import { CommandInteraction } from "discord.js";
3import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
pineafan4edb7762022-06-26 19:21:04 +01004import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan63fc5e22022-08-04 22:04:10 +01005import client from "../../utils/client.js";
pineafan4f164f32022-02-26 22:07:12 +00006
7const command = (builder: SlashCommandSubcommandBuilder) =>
Skyler Grey75ea9172022-08-06 10:22:23 +01008 builder.setName("ping").setDescription("Gets the bot's ping time");
pineafan4f164f32022-02-26 22:07:12 +00009
pineafanbd02b4a2022-08-05 22:01:38 +010010const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan377794f2022-04-18 19:01:01 +010011 // WEBSOCKET | Nucleus -> Discord
12 // EDITING | Nucleus -> discord -> nucleus | edit time / 2
pineafan63fc5e22022-08-04 22:04:10 +010013 const initial = new Date().getTime();
Skyler Grey75ea9172022-08-06 10:22:23 +010014 await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
pineafan63fc5e22022-08-04 22:04:10 +010015 const ping = new Date().getTime() - initial;
Skyler Grey75ea9172022-08-06 10:22:23 +010016 interaction.editReply({
17 embeds: [
18 new EmojiEmbed()
19 .setTitle("Ping")
20 .setDescription(
21 `**Ping:** \`${ping}ms\`\n` +
22 `**To Discord:** \`${client.ws.ping}ms\`\n` +
Skyler Grey11236ba2022-08-08 21:13:33 +010023 `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\``
Skyler Grey75ea9172022-08-06 10:22:23 +010024 )
25 .setEmoji("CHANNEL.SLOWMODE.OFF")
26 .setStatus("Danger")
27 ]
28 });
pineafan63fc5e22022-08-04 22:04:10 +010029};
pineafan4f164f32022-02-26 22:07:12 +000030
pineafanbd02b4a2022-08-05 22:01:38 +010031const check = () => {
pineafan4f164f32022-02-26 22:07:12 +000032 return true;
pineafan63fc5e22022-08-04 22:04:10 +010033};
pineafan4f164f32022-02-26 22:07:12 +000034
35export { command };
36export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010037export { check };