mirror of
https://github.com/arthur-pbty/flint.git
synced 2026-08-04 20:29:11 +02:00
- Add `defineCommand` function to validate and normalize command inputs. - Introduce `deployApplicationCommands` for deploying slash commands to Discord. - Create `CommandRegistry` class for managing command registration and retrieval. - Implement `buildSlashPayload` to construct slash command payloads with localization support. - Add usage utilities for prefix and slash commands. - Develop `CommandExecutor` to handle command execution with permission checks and cooldown management. - Create member message rendering service for welcome and leave messages with customizable templates. - Introduce presence template variables for dynamic bot status updates. - Implement template variable utilities for rendering and extracting variables from strings.
33 lines
850 B
TypeScript
33 lines
850 B
TypeScript
/**
|
|
* Commande `ping` (utility)
|
|
*
|
|
* Répond avec un message court contenant la latence websocket du bot.
|
|
*/
|
|
import { MessageFlags } from "discord.js";
|
|
import { defineCommand } from "../core/commands/defineCommand.js";
|
|
|
|
/** Commande `ping` — affiche la latence du bot. */
|
|
export const pingCommand = defineCommand({
|
|
meta: {
|
|
name: "ping",
|
|
category: "utility",
|
|
},
|
|
cooldown: 5,
|
|
examples: [
|
|
{
|
|
descriptionKey: "examples.basic",
|
|
},
|
|
],
|
|
execute: async (ctx) => {
|
|
const responses = (ctx.commandText.responses as Record<string, unknown> | undefined) ?? {};
|
|
const template = typeof responses.pong === "string" ? responses.pong : "Pong {{latency}}ms";
|
|
|
|
await ctx.reply({
|
|
content: ctx.format(template, {
|
|
latency: ctx.client.ws.ping,
|
|
}),
|
|
flags: [MessageFlags.Ephemeral],
|
|
});
|
|
},
|
|
});
|