Template for slash commands in discord.js made with Typescript.
This template made for private projects (single server).
- Permission system
- You can create commands available for custom permissions.
- Developer only commands
- You can create commands only available for developers.
- Disable commands
- You can disable the commands if you don't want to use.
You can use npm
instead of yarn
but i recommended to use yarn
.
yarn install
- Rename
.env.example
to.env
and fill it. - If you want to change intents, edit
src/structures/CustomClient.ts
.
- Without Building
- Type
yarn dev
to run.
- Type
- With Building
- Type
yarn build
to build the project. - Type
yarn start
to run the builded project.
- Type
Never use interaction#reply
method because in the handler we're deffering it. Use interaction#followUp
method for replying.
import { CommandInteraction } from 'discord.js';
import { SlashCommandBuilder } from '@discordjs/builders';
import { Command } from '../structures/Command';
export default new Command({
builder: new SlashCommandBuilder()
.setName('ping')
.setDescription('Replies with pong.'),
run: async ({ interaction }) => {
// Bad, will throw error
await interaction.reply('Pong');
// Good
await interaction.followUp('Pong');
}
});
If you find this project useful and would like to support me, you can do so by visiting my website.