Discord bot handler written in TypeScript. This repository provides a small framework for loading events, commands and components dynamically and starting a Discord bot using discord.js.
- Dynamic loading of events, commands and components from
src/ - Built-in i18n support using
src/localesandlocales.json - Simple utilities for file loading and bootstrapping
- Production-ready build helper that copies runtime assets to
dist/
- Node.js 18+ (or compatible) and npm
- A Discord bot token (set as
SECRETin environment)
Clone the repository and install dependencies:
git clone https://github.com/xyligan-gp/discord-bot-handler.git
cd discord-bot-handler
npm installCreate a .env file in the project root with at least the bot token:
SECRET=your_discord_bot_token
DEFAULT_LOCALE=en-US # optional
DEBUG=false # optional, set to true for debug logging
Locales are defined under src/locales and referenced by locales.json.
npm run dev— start in development mode (usesnodemon+tsx)npm run start— run the compiled project (node .)npm run build— compile TypeScript (tsc -p tsconfig.json)npm run build:prod— compile and runcp.tsto copy runtime files todist/npm run updater— run the updater script
Example: run in development:
npm run devThe cp.ts helper copies runtime assets (locales, locales.json, tsconfig.json,
.env, package.json, updater.js) into dist/ so the compiled code can be
deployed in a single folder. Use npm run build:prod for a basic production
build flow.
Key folders and files:
index.ts— program entry that instantiatesBotServicesrc/app.service.ts— bootstraps the bot, logger and i18nsrc/app.class.ts—Botclass extendingdiscord.jsClientsrc/utils— helper utilities (dynamic file loader)src/commands— command handlerssrc/events— event handlerssrc/components— component-like handlerssrc/locales— locale JSON fileslocales.json— list of available locales used by i18n
SECRET(required) — Discord bot tokenDEFAULT_LOCALE(optional) — default locale key fromlocales.jsonDEBUG(optional) — whentrueenables debug logging
Contributions are welcome. Open an issue or submit a pull request.
This project is licensed under the Apache-2.0 License. See LICENSE.
xyligan — contact.csdevs@gmail.com
Report bugs at: https://github.com/xyligan-gp/discord-bot-handler/issues