blob: 63538434793811d8b8075e8a1f4bf24ef6b7e54a [file] [log] [blame]
pineafane23c4ec2022-07-27 21:56:27 +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";
pineafan4f164f32022-02-26 22:07:12 +00005import { WrappedCheck } from "jshaiku";
PineappleFanb3dd83c2022-06-17 10:53:48 +01006import client from "../../utils/client.js"
pineafan4f164f32022-02-26 22:07:12 +00007
8const command = (builder: SlashCommandSubcommandBuilder) =>
9 builder
10 .setName("ping")
11 .setDescription("Gets the bot's ping time")
12
pineafan4edb7762022-06-26 19:21:04 +010013const callback = async (interaction: CommandInteraction): Promise<any> => {
pineafan377794f2022-04-18 19:01:01 +010014 // WEBSOCKET | Nucleus -> Discord
15 // EDITING | Nucleus -> discord -> nucleus | edit time / 2
16 let initial = new Date().getTime();
pineafane23c4ec2022-07-27 21:56:27 +010017 await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
pineafan377794f2022-04-18 19:01:01 +010018 let ping = new Date().getTime() - initial;
pineafan4edb7762022-06-26 19:21:04 +010019 interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010020 .setTitle("Ping")
21 .setDescription(
22 `**Ping:** \`${ping}ms\`\n` +
PineappleFanb3dd83c2022-06-17 10:53:48 +010023 `**To Discord:** \`${client.ws.ping}ms\`\n` +
24 `**From Expected:** \`±${Math.abs((ping / 2) - client.ws.ping)}ms\``
pineafan377794f2022-04-18 19:01:01 +010025 )
26 .setEmoji("CHANNEL.SLOWMODE.OFF")
27 .setStatus("Danger")
28 ]})
pineafan4f164f32022-02-26 22:07:12 +000029}
30
31const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
32 return true;
33}
34
35export { command };
36export { callback };
37export { check };