This is a minimal architecture for building a discord bot in TypeScript, based on discord.js, injection.js and RxJS.
This template provides :
- A message sending in a text channel.
- A periodic sending of message in a text channel via Cron.
- A command builder with two examples (/help, /faq), and an Interaction listener.
- A command registerer.
Create an .env file at the root of your project and define your Discord bot token, Client ID and Guild ID in a variable as following:
TOKEN="Your_token_here"
CLIENT_ID="Your_client_id_here"
GUILD_ID="Your_guild_id_here"
The channel IDs are defined in src/infra/channels-static.json
[
{
"key": "custom_key",
"id": "channel_id"
}
]
npm install
npm run build
npm run deploy-commands
npm start
npm run deploy-commands:dev
npm start:dev
- discord.js: Node.js module to interact with the Discord API.
- vite-note: Vite as Node runtime.
- TypeScript: JavaScript with syntax for types.
- RxJS: Reactive Extensions Library for JavaScript.
- injection-js: Dependency injection library for JavaScript and TypeScript.