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