How to set up a Discord Bot? This guide is going to be a short one on how to do so. (Using Discord.js) Information to read before we get started:
- Documentation: https://discord.js.org/#/docs/main/stable/general/welcome
- Discord App Development: https://discord.com/developers/applications
- Things to have installed: Node.js, Visual Studio Code (I assume you have these already)
Detailed Steps
- Create a new folder wherever you want to within VSCode
- Run the following commands in this order:
npm init
(just spam return here) andnpm install discord.js --save
. This creates a file called "package.json" - Run the following commands here:
npm install
andnpm install nodemon
. - In the section of the file marked
scripts
, copy this line underneath what should be there:"start": "nodemon ./index.js"
(add a comma at the end of what is there already) - Now navigate to the Discord app development site, login, then hit "New Appication"
- Enter a name for your application
- Now navigate over to Bots tab, hit create a bot and confirm, then copy the API Token
- In VSCode, create a file "config.json" and reference the file. Copy the API token to the
API_TOKEN
field, and change theprefix
field to whatever you'd like - Lastly, create a file "index.js", go to the documentation, and paste that introductory code at the front. Or copy the one from the given file
- To run the bot, just type
npm start
in the VSCode terminal