trail-command-handler
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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
}

Package Sidebar

Install

npm i trail-command-handler

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

10 kB

Total Files

12

Last publish

Collaborators

  • geloocg