blob: 105cda520fec62dc40644aa1d0118c877a1cacd9 [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` +
23 `**From Expected:** \`±${Math.abs(
24 ping / 2 - client.ws.ping
25 )}ms\``
26 )
27 .setEmoji("CHANNEL.SLOWMODE.OFF")
28 .setStatus("Danger")
29 ]
30 });
pineafan63fc5e22022-08-04 22:04:10 +010031};
pineafan4f164f32022-02-26 22:07:12 +000032
pineafanbd02b4a2022-08-05 22:01:38 +010033const check = () => {
pineafan4f164f32022-02-26 22:07:12 +000034 return true;
pineafan63fc5e22022-08-04 22:04:10 +010035};
pineafan4f164f32022-02-26 22:07:12 +000036
37export { command };
38export { callback };
Skyler Grey75ea9172022-08-06 10:22:23 +010039export { check };