A typescript discord.js bot template using typeorm with mysql
- Clone this repository
- After done fill config.json with your prefered ids
- Update ormconfig.json file with DB ids
- Add your bot token in .env file (if you haven't bot token go to the Discord Developer Portal then create a new application)
- Start command prompt in project folder
- Run
npm install
to install all project dependencies
All commands are in SlashCommands. So they go through the interactionCreate
event. You can always add prefixed commands by modifying the code a bit.
By default there is a ping
command to show the use of the template.
The template contains a connection to a database with the typeorm and mysql2 packages. If you don't know how to use one of them, don't hesitate to have a look at the documentation.
The connection information is in the ormconfig.json
file, it allows the connection to a mysql database hosted in localhost. You can also edit the file so that you don't see SQL queries executed by typeorm by setting the logging: false
property to false. You can also disable automatic entity synchronization (default is on).
You will find in the utils
folder some utilities.
Run commande npm run build
this will compile typescript in a dist
folder in project folder.
Edit the APP_ENV
propertie by dev
in the .env file. Then run in command prompt npm run start:dev
.
The bot will start and automatically restart if there is a change in your project folder.
Set APP_ENV
at live
, don't forget to fill the config.json
live section with your ids and other info. Then run npm run start:prod
. This will start the bot after finish to compile it.
You can also start the bot without compile it by running npm run start
.
Note for this command you can replace
node
bynodemon
to automatically restart bot on dist folder change.
This is a template so you can update, modify it as you want. If you have suggest to upgrade this repository, please do a pull request.
Hokanosekai#0001