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"; |
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 | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 12 | const callback = async (interaction: CommandInteraction) => { |
| 13 | // WEBSOCKET | Nucleus -> Discord |
| 14 | // EDITING | Nucleus -> discord -> nucleus | edit time / 2 |
| 15 | let initial = new Date().getTime(); |
| 16 | await interaction.reply({embeds: [new generateEmojiEmbed() |
| 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; |
| 23 | interaction.editReply({embeds: [new generateEmojiEmbed() |
| 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 }; |