pineafan | e23c4ec | 2022-07-27 21:56:27 +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"; |
PineappleFan | b3dd83c | 2022-06-17 10:53:48 +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 |
| 10 | .setName("ping") |
| 11 | .setDescription("Gets the bot's ping time") |
| 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 |
| 16 | let initial = new Date().getTime(); |
pineafan | e23c4ec | 2022-07-27 21:56:27 +0100 | [diff] [blame] | 17 | await interaction.reply({embeds: LoadingEmbed, ephemeral: true}); |
pineafan | 377794f | 2022-04-18 19:01:01 +0100 | [diff] [blame] | 18 | let 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") |
| 28 | ]}) |
pineafan | 4f164f3 | 2022-02-26 22:07:12 +0000 | [diff] [blame] | 29 | } |
| 30 | |
| 31 | const check = (interaction: CommandInteraction, defaultCheck: WrappedCheck) => { |
| 32 | return true; |
| 33 | } |
| 34 | |
| 35 | export { command }; |
| 36 | export { callback }; |
| 37 | export { check }; |