Skip to content

Commit 56f3b82

Browse files
authored
Merge pull request #50 from ICEPrey/ping-command
feat: ping util command
2 parents b256a17 + 88d55f9 commit 56f3b82

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/commands/utility/ping.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import {
2+
ChatInputCommandInteraction,
3+
EmbedBuilder,
4+
SlashCommandBuilder,
5+
} from "discord.js";
6+
import { randomColor } from "../../helpers/colors";
7+
8+
export const data = new SlashCommandBuilder()
9+
.setName("ping")
10+
.setDescription("Get the bot's ping");
11+
12+
export async function execute(interaction: ChatInputCommandInteraction) {
13+
const reply = await interaction.reply({
14+
ephemeral: true,
15+
fetchReply: true,
16+
embeds: [
17+
new EmbedBuilder()
18+
.setDescription("Calculating ping...")
19+
.setColor(randomColor()),
20+
],
21+
});
22+
const embed = new EmbedBuilder()
23+
.setDescription(
24+
`Pong! Latency is ${
25+
reply.createdTimestamp - interaction.createdTimestamp
26+
}ms`,
27+
)
28+
.setColor(randomColor());
29+
30+
await interaction.editReply({
31+
embeds: [embed],
32+
});
33+
}

0 commit comments

Comments
 (0)