blob: c153e197187c185438bde99fac06b13692c6b03d [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";
pineafan4f164f32022-02-26 22:07:12 +00005import { WrappedCheck } from "jshaiku";
pineafan63fc5e22022-08-04 22:04:10 +01006import client from "../../utils/client.js";
pineafan4f164f32022-02-26 22:07:12 +00007
8const command = (builder: SlashCommandSubcommandBuilder) =>
9 builder
pineafan63fc5e22022-08-04 22:04:10 +010010 .setName("ping")
11 .setDescription("Gets the bot's ping time");
pineafan4f164f32022-02-26 22:07:12 +000012
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
pineafan63fc5e22022-08-04 22:04:10 +010016 const initial = new Date().getTime();
pineafane23c4ec2022-07-27 21:56:27 +010017 await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
pineafan63fc5e22022-08-04 22:04:10 +010018 const 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")
pineafan63fc5e22022-08-04 22:04:10 +010028 ]});
29};
pineafan4f164f32022-02-26 22:07:12 +000030
31const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => {
32 return true;
pineafan63fc5e22022-08-04 22:04:10 +010033};
pineafan4f164f32022-02-26 22:07:12 +000034
35export { command };
36export { callback };
37export { check };