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