PineaFan | 0d06edc | 2023-01-17 22:10:31 +0000 | [diff] [blame] | 1 | import { LoadingEmbed } from "../../utils/defaults.js"; |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 2 | import type { CommandInteraction } from "discord.js"; |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 3 | import type { SlashCommandSubcommandBuilder } from "discord.js"; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 4 | import EmojiEmbed from "../../utils/generateEmojiEmbed.js"; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 5 | import client from "../../utils/client.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 6 | |
| 7 | const command = (builder: SlashCommandSubcommandBuilder) => |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 8 | builder.setName("ping").setDescription("Gets the bot's ping time"); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 9 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame] | 10 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 11 | // WEBSOCKET | Nucleus -> Discord |
| 12 | // EDITING | Nucleus -> discord -> nucleus | edit time / 2 |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 13 | const initial = Date.now(); |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 14 | await interaction.reply({ embeds: LoadingEmbed, ephemeral: true }); |
Samuel Shuert | 27bf3cd | 2023-03-03 15:51:25 -0500 | [diff] [blame] | 15 | const ping = Date.now() - initial; |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 16 | interaction.editReply({ |
| 17 | embeds: [ |
| 18 | new EmojiEmbed() |
| 19 | .setTitle("Ping") |
| 20 | .setDescription( |
| 21 | `**Ping:** \`${ping}ms\`\n` + |
PineaFan | 538d375 | 2023-01-12 21:48:23 +0000 | [diff] [blame] | 22 | `**To Discord:** \`${client.ws.ping}ms\`\n` + |
| 23 | `**From Expected:** \`±${Math.abs(ping / 2 - client.ws.ping)}ms\`` |
Skyler Grey | 75ea917 | 2022-08-06 10:22:23 +0100 | [diff] [blame] | 24 | ) |
| 25 | .setEmoji("CHANNEL.SLOWMODE.OFF") |
| 26 | .setStatus("Danger") |
| 27 | ] |
| 28 | }); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 29 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 30 | |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 31 | export { command }; |
| 32 | export { callback }; |