trail-command-handler
v1.0.1
Published
this uti[C[C package is used to easily handle commands for you discord.js bot.
Maintainers
Readme
trail command handler v1.0.1
The Trail Command Handler allow you to easily setup slash commands in your discord application well typed.
How to use ?
// index.ts
import { Client } from "discord.js";
import { SlashCommandHandler } from "trail-command-handler";
import { PingCommand } from "commands.ts";
const client = new Client({ intents: ["Guilds"] });
const commandHandler = new SlashCommandHandler(client);
(async () => {
await client.login(process.env.TOKEN);
await commandHandler.handleCommands({
commands: [new PingCommand()],
devGuild: client.guilds.cache.get(process.env.DEV_GUILD_ID), // Remove this if you want to register commands globally
});
})();// PingCommand.ts
import {Command} from "trail-command-handler";
import {SlashCommandBuilder, type CommandInteraction} from "discord.js";
export class PingCommand extends Command {
constructor() {
super(){
return new SlashCommandBuilder()
.setName('ping')
.setDescription('pong!')
}
}
execute(interaction: CommandInteraction) {...} // Can be async or not
}