This is a basic structure for a typescript discord bot.
-
Clone this repository with the command
git clone https://github.com/Guscraftin/Base_DiscordBot.git
. You need to have git installed on your machine. If your machine doesn't recognize thegit
command, install it via this link: https://git-scm.com/download/. Once git is installed, openGit Bash
(if you are on Windows) to execute git commands. -
Go to the root of the directory you just downloaded (using the command
cd Base_DiscordBot
) and run the command:npm i
.
You need to have Node.js installed on your machine. If your machine doesn't recognize the npm command, install it via this link: https://nodejs.org/en/download/. -
Rename the
.env.example
file to.env
. -
Open the
.env
file and replace the...
with your own values. -
To obtain these values, follow these steps:
- Go to https://discord.com/developers/applications and create a new application by clicking the button at the top right. Enter your bot's name, agree to the terms of service, and then click "Create".
- In the "Bot" section, click "Reset Token", then click the "Copy" button to copy the bot token that appears. Replace the
...
with this token in theTOKEN=
variable in the.env
file. - In the "OAuth2" section, click "Copy" under the client ID. Replace the
...
with this ID in theCLIENT_ID=
variable in the.env
file. - Enable developer mode in your Discord settings by going to user settings, then the "Advanced" section. Right-click the server where you want to invite the bot, then click "Copy ID". Replace the
...
with this ID in theGUILD_ID=
variable in the.env
file.
-
To invite the bot to your server, follow these steps:
- Go back to https://discord.com/developers/applications and select your bot application.
- Click on the "OAuth2" section and then on "URL Generator". In the "Scope" field, select "bot". Choose the permissions you want to grant the bot when it joins a Discord server. If you want to give it all permissions, you can grant it administrator permission.
- Once you've made your selections, copy the generated URL and paste it into your browser to add the bot to the server where you previously copied the ID.
- Run the command npm start in the previously cloned folder.