blob: ab23bf7562dfcb000744947c0ec2911db8ecc45a [file] [log] [blame]
pineafan4f164f32022-02-26 22:07:12 +00001import { CommandInteraction } from "discord.js";
2import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
pineafan377794f2022-04-18 19:01:01 +01003import generateEmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan4f164f32022-02-26 22:07:12 +00004import { WrappedCheck } from "jshaiku";
5
6const command = (builder: SlashCommandSubcommandBuilder) =>
7 builder
8 .setName("ping")
9 .setDescription("Gets the bot's ping time")
10
pineafan377794f2022-04-18 19:01:01 +010011const callback = async (interaction: CommandInteraction) => {
12 // WEBSOCKET | Nucleus -> Discord
13 // EDITING | Nucleus -> discord -> nucleus | edit time / 2
14 let initial = new Date().getTime();
15 await interaction.reply({embeds: [new generateEmojiEmbed()
16 .setTitle("Ping")
17 .setDescription(`Checking ping times...`)
18 .setEmoji("NUCLEUS.LOADING")
19 .setStatus("Danger")
20 ], ephemeral: true});
21 let ping = new Date().getTime() - initial;
22 interaction.editReply({embeds: [new generateEmojiEmbed()
23 .setTitle("Ping")
24 .setDescription(
25 `**Ping:** \`${ping}ms\`\n` +
26 `**To Discord:** \`${interaction.client.ws.ping}ms\`\n` +
27 `**From Expected:** \`±${Math.abs((ping / 2) - interaction.client.ws.ping)}ms\``
28 )
29 .setEmoji("CHANNEL.SLOWMODE.OFF")
30 .setStatus("Danger")
31 ]})
pineafan4f164f32022-02-26 22:07:12 +000032}
33
34const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
35 return true;
36}
37
38export { command };
39export { callback };
40export { check };