Welcome, this is a powerful TypeScript handler available for discord.js v13. The aim of this handler is to allow developers to skip the tedious process of having to create a handler for their project(s). The process of doing this is redundant and takes unecessary time. With that in mind, the handlers offer:
- Easy set up, everything is documented.
- Basic handler without mongo & advanced handler with mongo.
- Very performant & clean code.
- 100% coverage of the Discord API.
Node.js 16.6.0 & npm 7.0.0 or newer is required.
npm install -y
- Go to the
src/config
folder. - Input the respective config options.
- Add your Discord User ID in the
DEVS
array. - Add your Support/Test Server ID in the
DEV_SERVERS
array. - Optional: Add your own emotes in the
EMOTES
object. - Optional: Add your MongoDB URI. This step is only needed if you are not using the basic handler(s).
import { CommandInteraction } from 'discord.js';
import { Command } from '../../utils/command';
import { Client } from '../../utils/client';
export default class Template extends Command {
constructor (client: Client) {
super(client, {
name: 'template',
description: 'This is a template'
});
}
async execute ({ client, interaction }: { client: Client, interaction: CommandInteraction }): Promise<void> {
//
}
}
import { CommandInteraction } from 'discord.js';
import { Command } from '../../utils/command';
import { Client } from '../../utils/client';
export default class Template extends Command {
constructor (client: Client) {
super(client, {
name: 'template',
description: 'This is a template',
subcommands: {
command1: {
description: 'The description for the first sub command.',
execute: async ({ client, interaction }: { client: Client, interaction: CommandInteraction }): Promise<void> => {
//
}
},
command2: {
description: 'The description for the first sub command.',
execute: async ({ client, interaction }: { client: Client, interaction: CommandInteraction }): Promise<void> => {
//
}
}
}
});
}
}
- Create your new command file, ending in the
.ts
file extension. - Change the class name from "Template" to your command name.
- Change the command name to your new command name.
- Add a meaningful description for your new command.
- Voila! You can now add any new options.
- If you would like your command registered as a global command, set
development
tofalse
.
import { Client } from '../../utils/client';
export default async (client: Client): Promise<void> => {
//
};
- Create your new event file, ending in the
.ts
file extension.- The file name needs to be the event name!
- Add the necessary parameters.
- Voila! Your event is now added!