blob: f10dcaeddd394f594e89141d9a41f3420f146442 [file] [log] [blame]
pineafan4f164f32022-02-26 22:07:12 +00001import { CommandInteraction } from "discord.js";
2import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
pineafan4edb7762022-06-26 19:21:04 +01003import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
pineafan4f164f32022-02-26 22:07:12 +00004import { WrappedCheck } from "jshaiku";
PineappleFanb3dd83c2022-06-17 10:53:48 +01005import client from "../../utils/client.js"
pineafan4f164f32022-02-26 22:07:12 +00006
7const command = (builder: SlashCommandSubcommandBuilder) =>
8 builder
9 .setName("ping")
10 .setDescription("Gets the bot's ping time")
11
pineafan4edb7762022-06-26 19:21:04 +010012const callback = async (interaction: CommandInteraction): Promise<any> => {
pineafan377794f2022-04-18 19:01:01 +010013 // WEBSOCKET | Nucleus -> Discord
14 // EDITING | Nucleus -> discord -> nucleus | edit time / 2
15 let initial = new Date().getTime();
pineafan4edb7762022-06-26 19:21:04 +010016 await interaction.reply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010017 .setTitle("Ping")
18 .setDescription(`Checking ping times...`)
19 .setEmoji("NUCLEUS.LOADING")
20 .setStatus("Danger")
21 ], ephemeral: true});
22 let ping = new Date().getTime() - initial;
pineafan4edb7762022-06-26 19:21:04 +010023 interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010024 .setTitle("Ping")
25 .setDescription(
26 `**Ping:** \`${ping}ms\`\n` +
PineappleFanb3dd83c2022-06-17 10:53:48 +010027 `**To Discord:** \`${client.ws.ping}ms\`\n` +
28 `**From Expected:** \`±${Math.abs((ping / 2) - client.ws.ping)}ms\``
pineafan377794f2022-04-18 19:01:01 +010029 )
30 .setEmoji("CHANNEL.SLOWMODE.OFF")
31 .setStatus("Danger")
32 ]})
pineafan4f164f32022-02-26 22:07:12 +000033}
34
35const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
36 return true;
37}
38
39export { command };
40export { callback };
41export { check };