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