blob: 3e02a8fef9fc4e098517b42a31c51306db238fec [file] [log] [blame]
PineaFan0d06edc2023-01-17 22:10:31 +00001import { LoadingEmbed } from "../../utils/defaults.js";
PineaFan538d3752023-01-12 21:48:23 +00002import type { CommandInteraction } from "discord.js";
TheCodedProff86ba092023-01-27 17:10:07 -05003import type { SlashCommandSubcommandBuilder } from "discord.js";
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
TheCodedProf6ec331b2023-02-20 12:13:06 -050013 const initial = Date.now();
Skyler Grey75ea9172022-08-06 10:22:23 +010014 await interaction.reply({ embeds: LoadingEmbed, ephemeral: true });
TheCodedProf6ec331b2023-02-20 12:13:06 -050015 const ping = Date.now() - 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` +
PineaFan538d3752023-01-12 21:48:23 +000022 `**To Discord:** \`${client.ws.ping}ms\`\n` +
23 `**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
pineafan4f164f32022-02-26 22:07:12 +000031export { command };
32export { callback };