Updating config.json
When you want to start using a database, youll be provided with some sensitive information that will be used to connect to it. Just like your bot token, databases also have "tokens" (we refer to them as strings) to connect to them.
Its very important you keep this string a secret or anyone can access your database and manipulate it however they like.
To do this, you want to create another entree in your config.json file, and call it databaseString. Your config.json should now follow a structure like this:
{
"token": "Paste Token Here",
"databaseString": "Paste String Here"
}Now, the same way you did in the index.js, you can require this file in your database connection file, and refer to it using config.databaseString
Example:
Create a new file in your /source/events/ready/ directory, and for this case, we will be naming it database-connection.js (You can call this whatever you would like).
At the top of this file, add this line:
const config = require('../../config.json');Now, in the next page Connectingyou will learn how to connect to the database.
Last updated