Template repo: https://github.com/alvesvaren/discord-ts-template
This is a simple template to create discord bots with typescript and slash commands using discord.js. Mostly based on the official docs, but has some extra features and structure out of the box
- Create a bot on https://discord.com/developers
- Create repo based on template, clone it and install packages with
yarn
(to use another package manager, removeyarn.lock
and update the scripts section ofpackage.json
) - Copy
.env.example
to.env
and populate it with your bot token - Run the bot using
yarn start
You can deploy this however you want, but I've added a nixpacks config to make it easy to use railway.app (referral link), or easily deploy it manually as a container using nixpacks.
- index.ts - code to run the bot
- .env - contains environment variables that will be loaded when starting
- .env.example - template for .env
- types.ts - the types used for commands
- commands/ - where you put slash-commands for the bot
- echo.ts - the command echo, can be copied and changed as needed