Advanced v14 prefix and slash command discord bot
Easy to use and beginner friendly package that offers the use of both slash commands and prefix command as well as database connection using mongoDB. Easy to set up and get started in. Comes with a few basic starter commands and events such as command logging, guild create & delete events and more...
⭐ If your a fan of this repository or have used it or any of it's code, please consider leaving us a star. It would be greatly appreciated and allows us to see if users value the bot! ⭐
- Download Node.js.
- Download Visual Studio Code.
-
Project Setup
-
Fork the Github project :
-
Click the
Codebutton. From the drop-down that appears, clickDownload ZIPto download the entire repository as a ZIP folder. -
Extract the files to a new folder and open it with Visual Studio Code.
-
-
Obtain Discord Bot Token
-
Sign in to Discord Developer Portal.
-
Create a bot :
- Enter the left side
Applications. - Click
New Applicationin the upper right corner and enter the name of the bot. After confirmation, enter the new page. - Click on the left side
Bot. - Enable all intents listed under
Privileged Gateway Intentsand clickSave Changes. - View and copy the token by clicking the
Reset Tokenbutton.
- Enter the left side
-
Set up OAuth2 :
- Click on
OAuth2in the left column. - Click on
URL Generatorin the left column. - In the right column, select
botandapplications.commandsunderSCOPES. - Scroll down and select
AdministratorunderBOT PERMISSIONS. - Copy the URL at the bottom and paste it into your browser.
- Choose the server you want to add the bot to and click
Continue>Authorize.
- Click on
-
-
Obtain MongoDB Connection String
- Sign up / Sign in to MongoDB.
- Choose your preferred cloud database plan.
- Customize the cluster settings to your preference and click
Create Cluster. - Navigate to the
Network Accesspage, clickAdd IP Addressand selectAllow access from anywhere. - Navigate back to the
Databasepage and clickConnect. - Create a
database user, clickChoose a connection methodand selectConnect your application. - Copy your connection string and replace
<password>with the password for the database user that you created earlier.
-
Setting up the env file
If you go along with this, you can ignore the parts in the
Project Executionthat explain how to generate and fill in the.env- For easy setup of the env file, (
.env) you can run the commandnpm run setup-env - Once you've ran the command, it generates a script in the console
- You need to then fill out the fields in the console. Fields marked with the text "Required" are you required fields and you need to fill those ones in. The script will not continue if you ignore to fill in those fields.
- Once you've filled in the field, it will write those fields into and generate the
.env. - Alternatively, you can ignore this and fill in the fields yourself by viewing the
.example.envfile. - You then should be good, and your
.envshould be setup.
- For easy setup of the env file, (
-
Project Execution
- Rename the filed named
example.envto.env - Navigate to the
Botpage on the Discord Developer Portal and clickReset Token. Afterwards, create a.envfile within the root directory. - Paste your bot token into the
tokenvariable inside the.envfile. - Paste your MongoDB connection string into the
mongodbvariable inside the.envfile. - Navigate to the
OAuth2page and copy theCLIENT ID. - Paste your client ID into the
clientidvariable inside the.envfile. - Navigate to your discord server, enable developer mode and right click the dropdown beside the server name.
- Click
Copy Server IDand paste it into theguildidvariable inside the.envfile. - Navigate to the
package.jsonfile and pay attention to the runnable commands listed underscripts. - Open the terminal in Visual Studio Code and install all necessary packages using
npm run setup. This will install the dependencies and give you a brief install guide - Open a new terminal and type
npm run startto run the file without using nodemon ornpm run start:nodemonto run the bot with nodemon. - The bot should then turn online, you should be able to see this by the console logs that is setup upon start up
- Rename the filed named
-
Runnable commands (scripts)
npm run start -
This starts up the bot with the contents from the.envfile. Essentially the same as runningnode .npm run setup-env -
To run the setup of the.envfile you can run the commandnpm run setup-env, this generates a script in the console that generates a.envfile and where you fill out the fields with whats required for the.envfile and it writes it in the file.
Connect with us on Discord for support / any related inquiry.
Released under the terms of MIT License license.
Thanks to thelegendev for the readme template from Nub Bot 💛
