mirror of
https://github.com/arthur-pbty/flint.git
synced 2026-08-01 20:29:03 +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.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { defineCommand } from "../src/core/commands/defineCommand.js";
|
|
|
|
test("defineCommand refuse un argument requis apres un optionnel", () => {
|
|
assert.throws(() => {
|
|
defineCommand({
|
|
meta: { name: "broken", category: "test" },
|
|
args: [
|
|
{ name: "optional", type: "string", required: false, descriptionKey: "args.optional" },
|
|
{ name: "required", type: "string", required: true, descriptionKey: "args.required" },
|
|
],
|
|
execute: async () => undefined,
|
|
});
|
|
});
|
|
});
|
|
|
|
test("defineCommand refuse un cooldown invalide", () => {
|
|
assert.throws(() => {
|
|
defineCommand({
|
|
meta: { name: "brokenCooldown", category: "test" },
|
|
cooldown: 0,
|
|
execute: async () => undefined,
|
|
});
|
|
});
|
|
});
|
|
|
|
test("defineCommand applique les valeurs par defaut", () => {
|
|
const command = defineCommand({
|
|
meta: { name: "ok", category: "test" },
|
|
execute: async () => undefined,
|
|
});
|
|
|
|
assert.deepEqual(command.args, []);
|
|
assert.deepEqual(command.permissions, []);
|
|
assert.deepEqual(command.examples, []);
|
|
assert.equal(command.cooldown, undefined);
|
|
});
|