Setting Up MongoDB

To be able to store data such as logs, you will need to use your own database. A database is required, as the database also stores configuration data for your bot.

Upon creating an account, you will be greeted with this page. Make sure you select Starter Cluster.

After this, you will be taken to the below screen:

Select one of the servers marked with FREE TIER AVAILABLE and click on Create Cluster. It will only take a couple of minutes to configure everything for you.

Follow the "Getting Started" tutorial on the bottom left.

Go to the Database Access section in the security tab. Click on + Add New User to create a new user, whereupon a new screen will pop up. Select Read and write to any database, so the bot can properly store the data. Choose a username and password, but make sure they both don't contain any special character like !, -, ?. Copy the password into your notepad.

Finally, click Add User to finish the creation.

Go to the Network Access section in the security tab. Click on + Add IP Address to add an IP address, whereupon a new screen will pop up. Click the Allow Access From Everywhere button and 0.0.0.0/0 should appear in the Whitelist Entry. Otherwise, make sure to put input that manually. Finally, click Confirm to confirm your changes.

The last part is to generate a Mongo URI. Go to the Clusters section in the Atlas tab. Click on Connect on the left side of your Cluster dashboard. This will open up a new screen where you have three options. For our purposes, select the middle option Connect Your Application.

You need to copy the connection string, which can be easily done by clicking the Copy button. Remove everything past <dbname> but keeping the /. Then replace <password> with the password for your user and <username> with your database-username, which you set earlier. Paste the URI in your notepad.

The final URI looks similar to this:

mongodb+srv://Username:[email protected]/.

Last updated