A simple Discord bot template written in TypeScript using discord.js. Easily extendable by adding your own slash commands.
- Node.js (v22+ recommended)
- A Discord bot token, client ID, and server (guild) ID
-
Clone the repository and install dependencies:
git clone <repo-url> cd discord-ticket-bot npm install
-
Create a
.envfile in thesrcfolder:TOKEN=YOUR_BOT_TOKEN CLIENT_ID=YOUR_CLIENT_ID GUILD_ID=YOUR_GUILD_IDReplace the values with your own.
-
Build the project:
npm run build
-
Deploy commands to Discord:
node dist/deploy-commands.js
-
Start the bot:
npm start
All commands are located in the src/commands folder. Each command is a separate .ts file that exports a default object with data and execute properties.
Example command file:
// filepath: src/commands/hello.ts
import { SlashCommandBuilder } from "discord.js";
export default {
data: new SlashCommandBuilder()
.setName("hello")
.setDescription("Greets the user!"),
async execute(interaction: any) {
await interaction.reply("Hello there!");
}
}```