mirror of
https://github.com/xHyroM/bun-discord-bot.git
synced 2024-12-22 12:11:06 +01:00
feat: ping command
This commit is contained in:
parent
f3d0fad63d
commit
47a186fd7d
4 changed files with 33 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
|||
import "./version.ts";
|
||||
import "./docs.ts";
|
||||
import "./tag.ts";
|
||||
import "./ping.ts";
|
||||
|
||||
import { registerCommands } from "../loaders/commands.ts";
|
||||
await registerCommands();
|
||||
|
|
30
src/commands/ping.ts
Normal file
30
src/commands/ping.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
import { defineCommand } from "../loaders/commands.ts";
|
||||
import { Bubu } from "../structs/Client.ts";
|
||||
import { InteractionCommandContext, MessageCommandContext } from "../structs/context/CommandContext.ts";
|
||||
|
||||
defineCommand({
|
||||
name: "ping",
|
||||
description: "pong",
|
||||
run: async(ctx: InteractionCommandContext) => {
|
||||
const message = await ctx.interaction.deferReply({
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
const restPing = message.createdTimestamp - ctx.interaction.createdTimestamp;
|
||||
|
||||
ctx.interaction.editReply({
|
||||
content: `🏓 WebSocket: \`${Bubu.ws.ping}ms\` | Rest: \`${restPing}ms\``
|
||||
});
|
||||
},
|
||||
runMessage: async(ctx: MessageCommandContext) => {
|
||||
const message = await ctx.reply({
|
||||
content: "🏓...",
|
||||
});
|
||||
|
||||
const restPing = message.createdTimestamp - ctx.message.createdTimestamp;
|
||||
|
||||
message.edit({
|
||||
content: `🏓 WebSocket: \`${Bubu.ws.ping}ms\` | Rest: \`${restPing}ms\``
|
||||
});
|
||||
}
|
||||
})
|
|
@ -19,7 +19,7 @@ export async function registerCommands() {
|
|||
.setName(d.name)
|
||||
.setDescription(d.description)
|
||||
.toJSON(),
|
||||
options: d.options
|
||||
options: d.options ?? []
|
||||
}))
|
||||
}
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ export interface StringOption {
|
|||
export interface Command {
|
||||
name: string;
|
||||
description: string;
|
||||
options: Option[];
|
||||
options?: Option[];
|
||||
run?: (
|
||||
context: CommandContext<true>
|
||||
) => any;
|
||||
|
|
Loading…
Reference in a new issue