Skip to content

A discord.js TypeScript bot template, with fully functional slash, regular command, component and event handlers.

License

Notifications You must be signed in to change notification settings

ayymaann/typescript-discord-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Discord Bot

A fully functional discord.js TypeScript bot template, with Slash & Regular text commands and events handlers.

Getting Started

Before doing anything else, it is important to complete this step before, and it is the __config.json file creation. To begin, create a folder called data in your root directory, inside that data folder, create another folder called json, inside it, create the __config.json file, and finally put inside it these informations:

{
 "client_id": "YOUR_CLIENT_ID",
 "_token": "YOUR_BOT_TOKEN",
 "_dbKey": "YOUR_MONGODB_KEY",
 "_defaultPrefix": ">>",
 "guilds": {
  "main": "YOUR_MAIN_GUILD_ID",
  "authorized": []
 }
}

Dependencies Installation

{
 "dependencies": {
 "discord.js": "^14.14.1",
 "fs": "^0.0.1-security",
 "mongoose": "^8.2.3",
 "pretty-ms": "^7.0.1"
 }
}

To install these libraries run in your terminal the following command:

npm install

You also need to install development dependencies:

{
 "devDependencies": {
 "@types/node": "^20.11.30",
 "tsx": "^4.7.1"
 }
}

To do so, run the following command:

npm install -D tsx @types/node

Globally install TypeScript:

npm install -g typescript

Running TypeScript Code

To run your TypeScript code, it is required to run the tsx watch src/index.ts command, whom alias is npm run dev.

npm run dev

However, it is not recommended to run your TypeScript code primarily due to performance issues. You will have to compile the TypeScript files to JavaScript files, in an automatically created dist folder.

  • To compile the TypeScript files to Javascript files, run the following command:
    npm run build
  • And finally, to run your compiled JavaScript files, run the follow command:
    npm run start
    or node .

About

A discord.js TypeScript bot template, with fully functional slash, regular command, component and event handlers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published