pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 1 | import { LoadingEmbed } from "./../../utils/defaultEmbeds.js"; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 2 | import { CommandInteraction } from "discord.js"; |
| 3 | import { SlashCommandSubcommandBuilder } from "@discordjs/builders"; |
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) => |
| 8 | builder |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 9 | .setName("ping") |
| 10 | .setDescription("Gets the bot's ping time"); |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 11 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame^] | 12 | const callback = async (interaction: CommandInteraction): Promise<void> => { |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 13 | // WEBSOCKET | Nucleus -> Discord |
| 14 | // EDITING | Nucleus -> discord -> nucleus | edit time / 2 |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 15 | const initial = new Date().getTime(); |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 16 | await interaction.reply({embeds: LoadingEmbed, ephemeral: true}); |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 17 | const ping = new Date().getTime() - initial; |
pineafan | 4edb776 | 2022-06-26 19:21:04 +0100 | [diff] [blame] | 18 | interaction.editReply({embeds: [new EmojiEmbed() |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 19 | .setTitle("Ping") |
| 20 | .setDescription( |
| 21 | `**Ping:** \`${ping}ms\`\n` + |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +0100 | [diff] [blame] | 22 | `**To Discord:** \`${client.ws.ping}ms\`\n` + |
| 23 | `**From Expected:** \`±${Math.abs((ping / 2) - client.ws.ping)}ms\`` |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 24 | ) |
| 25 | .setEmoji("CHANNEL.SLOWMODE.OFF") |
| 26 | .setStatus("Danger") |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 27 | ]}); |
| 28 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 29 | |
pineafan | bd02b4a | 2022-08-05 22:01:38 +0100 | [diff] [blame^] | 30 | const check = () => { |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 31 | return true; |
pineafan | 63fc5e2 | 2022-08-04 22:04:10 +0100 | [diff] [blame] | 32 | }; |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 33 | |
| 34 | export { command }; |
| 35 | export { callback }; |
| 36 | export { check }; |