blob: 91e8363f09a9f878e09d56f34759a9994a7bf42f [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) =>
8 builder
pineafan63fc5e22022-08-04 22:04:10 +01009 .setName("ping")
10 .setDescription("Gets the bot's ping time");
pineafan4f164f32022-02-26 22:07:12 +000011
pineafanbd02b4a2022-08-05 22:01:38 +010012const callback = async (interaction: CommandInteraction): Promise<void> => {
pineafan377794f2022-04-18 19:01:01 +010013 // WEBSOCKET | Nucleus -> Discord
14 // EDITING | Nucleus -> discord -> nucleus | edit time / 2
pineafan63fc5e22022-08-04 22:04:10 +010015 const initial = new Date().getTime();
pineafane23c4ec2022-07-27 21:56:27 +010016 await interaction.reply({embeds: LoadingEmbed, ephemeral: true});
pineafan63fc5e22022-08-04 22:04:10 +010017 const ping = new Date().getTime() - initial;
pineafan4edb7762022-06-26 19:21:04 +010018 interaction.editReply({embeds: [new EmojiEmbed()
pineafan377794f2022-04-18 19:01:01 +010019 .setTitle("Ping")
20 .setDescription(
21 `**Ping:** \`${ping}ms\`\n` +
PineappleFanb3dd83c2022-06-17 10:53:48 +010022 `**To Discord:** \`${client.ws.ping}ms\`\n` +
23 `**From Expected:** \`±${Math.abs((ping / 2) - client.ws.ping)}ms\``
pineafan377794f2022-04-18 19:01:01 +010024 )
25 .setEmoji("CHANNEL.SLOWMODE.OFF")
26 .setStatus("Danger")
pineafan63fc5e22022-08-04 22:04:10 +010027 ]});
28};
pineafan4f164f32022-02-26 22:07:12 +000029
pineafanbd02b4a2022-08-05 22:01:38 +010030const check = () => {
pineafan4f164f32022-02-26 22:07:12 +000031 return true;
pineafan63fc5e22022-08-04 22:04:10 +010032};
pineafan4f164f32022-02-26 22:07:12 +000033
34export { command };
35export { callback };
36export { check };