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 name
andProject Name
. SelectJavaScript
as your proffered language and clickcontinue
- For this example we will use the
FREE
cluster 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 Access
and clickAdd IP Address
and enter0.0.0.0/0
and clickconfirm
- On the left-hand side click
Database Access
and clickAdd New Database User
. Create a username and password and clickAdd User
Remember this password. - On the left-hand side click
Clusters
and clickConnect
Click on the second optionConnect Your Application
- Ensure the
Driver
isnode.js
and theversion
is3.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
.env
and inside type the following:MongoDB=""
Inside of the quotes paste your connection srting Replacing<password>
with your database user password and changingmyFirstDatabase
to something more appropriate
- Go to the Discord dev portal
- Click
New Application
on the top-right - Give it a name and click
Create
- On the left-hand side click
bot
and clickadd bot
This tells Discord you want this account to be abot account
- Under
Privileged Gateway Intents
ensureSERVER MEMBERS INTENT
is 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
OAuth2
and underscopes
checkbot
- Under
bot permissions
check 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
Scopes
an invite url has been generated with the required scopes. Use this to invite the bot to your guild. - On the left-hand side click
bot
and copy theTOKEN
It is important that you keep this secret. NEVER share this with anyone you do no trust. - Inside the
.env
file we created inStep 12
under 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.js
and 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.