This is a bare bones example Discord bot that's easy to use and easy to expand on. This is perfect for those who are new to creating Discord bots.
- Announce
- Ban
- Clear Warns
- Kick
- Purge
- Remove Warn
- Role add/remove
- Unban
- Warn
- Warns
- Server Info
- User Info
- Advice
- Chuck Norris
- gif
- Report
- Suggest
- Invite Manager
- Join/Leave
- Message Delete
- Message Update
- Word Filter
- Anti Advertisement
- A basic understanding of JavaScript is fundamental
- A basic understanding of Discord.js and Discord.commando is ideal but not necessary
- A basic understanding of MongoDB and Mongoose is ideal but not necessary
- Go to MongoDB
- Fill out your details and click
sign up - Fill in your
Organization nameandProject Name. SelectJavaScriptas your proffered language and clickcontinue - For this example we will use the
FREEcluster option on the right - Leave everything as default and change the cluster name if you wish
- Click
Create Cluster(This may take a few minutes) - On the left-hand side click
Network Accessand clickAdd IP Addressand enter0.0.0.0/0and clickconfirm - On the left-hand side click
Database Accessand clickAdd New Database User. Create a username and password and clickAdd UserRemember this password. - On the left-hand side click
Clustersand clickConnectClick on the second optionConnect Your Application - Ensure the
Driverisnode.jsand theversionis3.6 or later - Copy the connection string. It will look something like this:
mongodb+srv://TemplateBot:<password>@cluster0.pf4nz.mongodb.net/myFirstDatabase?retryWrites=true&w=majority - Inside our code editor create a file inside the root of the project called
.envand inside type the following:MongoDB=""Inside of the quotes paste your connection srting Replacing<password>with your database user password and changingmyFirstDatabaseto something more appropriate
- Go to the Discord dev portal
- Click
New Applicationon the top-right - Give it a name and click
Create - On the left-hand side click
botand clickadd botThis tells Discord you want this account to be abot account - Under
Privileged Gateway IntentsensureSERVER MEMBERS INTENTis enabled. Please note, Once your bot surpasses 100 servers your bot will need to be verified in order to use this intent. - On the left-hand side click
OAuth2and underscopescheckbot - Under
bot permissionscheck the following:
- View Audit Log
- Manage Server
- Manage Roles
- Manage Channels
- Kick Members
- Ban Members
- View Channels
- Send Messages
- Manage Messages
- Embed Links
- Read Message History
- Add Reactions
Alternatively just check the Admin permission Not Recommended
- Under
Scopesan invite url has been generated with the required scopes. Use this to invite the bot to your guild. - On the left-hand side click
botand copy theTOKENIt is important that you keep this secret. NEVER share this with anyone you do no trust. - Inside the
.envfile we created inStep 12under your MONGODB connection string addTOKEN=Please note, we do not use quotes""for here. - Paste your bot token after the
=and save.
- Assuming you have followed all steps above we are ready to bring the bot to life.
- Open up your terminal inside of your code editor and type
npm install. This will install all packages frompackage.json - Once this is done type
nodemon bot.jsand boom, It's alive!
You can reach me (VAL#0001) on my Discord Server
There are plenty of tutorials on YouTube for this. You are welcome to contact me for help and I will guide you through it but I will not explain it here.