This is a specialized Guide only made for this project to follow along.
If you need a complete git tutorial, watch this video by Kunal.
Well, before starting this tutorial I would like to say that these are some tested methods by us and are intended to be followed by all of our contributors.
- Follow this official guide from GitHub to properly Setup Git with GitHub. GitHub forces users to install their own GitHub CLI or GitHub Desktop Client, it is recommended to skip these steps and proceed with further steps in the guide.
- IMPORTANT: Install Node.js
v16.6.0
or higher. Ensure it'sv16.6.0
or higher. Follow this guide => Install/Upgrade Node.js tov16.6.0
or higher.
Go to the official repository and fork the project to your own account . Once you have forked it you must be able to see the fork of your own repo like username/discord-bot We'll talk more about those branches later.
Click on the green Code button and copy the SSH URL.(FROM THE FORK) Open your desired location on your local computer and right click to open Git Bash Paste the SSH URL in it.
git clone [email protected]:<user-name>/discord-bot.git && cd discord-bot
Add the upstream URL to your repo using this command
git remote add upstream [email protected]:NGIT-Open-Source/discord-bot.git
You can check the existing remotes using git remote -v
to verify if it has been added and origin + upstream exist independently and point to correct URL's
Well, git doesn't seem to properly clone the repo with all branches so we need to create develop
branch and add tracking so run this command
git checkout --track origin/develop
-
Checkout to development branch
git checkout develop
-
Make sure you've Node.js
v16.6.0
or higher installed. Follow this to install/upgrade Node.js -
Head to your project folder and run
npm ci
in the terminal. (This command installs all the required modules for the project mentioned inpackage-lock.json
in thenode_modules
directory.- Don't use
npm install
ornpm update
to install/update modules. Doing so might land you in a situation called Dependendency Hell whereas usingnpm ci
ensures you're working with exact versions of dependencies as other developers are. Know more about npm ci via this article or npm docs npm install <module-name>
can be used if you want to install an external npm module for a feature you're working on. Remember, As stated in npm-install docsnpm install
works entirely different as compared tonpm install <module-name>
- If you've used
npm install/update
unknowingly, Kindly refer this to fix conflicts
- Don't use
-
Finally, Follow the below steps if you want to run your own instance of bot for testing/development
- We would also highly suggest you to create your own server to test your bot out if you are new as we don't want to spam the main server.
-
Let's store secrets/tokens. Create a file with name
.env
and copy/paste template from.env.example
. Replace default values in.env
with your secrets/tokens.- Default values in
.env.example
are self-explanable and will guide you to fill values, open an issue if you need help - For security,
.env
will not be committed since it is added to.gitignore
- MAKE SURE NOT TO REVEAL YOUR TOKENS/SECRETS FROM
.env
ANYWHERE ELSE - Get the tokens/ids from Discord Dev portal. We recommend following official Discord.js docs to Setup Bot and adding it to your Server
- Default values in
-
Run
node deploy-commands.js
to register commands and then runnpm run dev
to start the bot. Refer Discord.js official guide if you run into errors.- Ensure to run
node deploy-commands.js
whenever a new slash command is added to the commands folder - Starting the bot with
npm run dev
will enable hot restart, which will auto restart the bot on each save. NOTE: Discord API blocks developers for a day if they start the bot 1000 times on a single day. Alternative[Only if you think you're going to re-start 1000 times]: Usenode .
ornode index.js
instead ofnpm run dev
and forget about hot restart. - If you've followed the above steps successfully, You should see your Bot live in discord, else you can always get help!
- Ensure to run
-
Make a commit on the current branch (develop) to mark creating of environment variable
git add . && git commit -m "Environment created"
-
To start working now that you are in the develop branch you need to create your own branch from develop , run :
git checkout -b *branch -name*
-
Once you are done implementing features or fixing bugs come down to Pushing Changes to show us your contributions✌
Non-code contributions include opening Issues regarding bugs/suggestions etc, Updating Docs through a PR and more.
Before making any contributions, We recommend you to learn the basics of JavasScript, Node.js and refer to the official guide and docs before making any changes to maintain code quality.
NOTE: We recommend opening an Issue first and link it to your PullRequest while opening a PR. It's considered a good practice and makes maintaining the codebase a lot easier.
Ask for help in our official NGIT discord server. We can help you in many ways
Help in learning JS : This project is based on Node.js v16.6.0
or higher. Either you already know the basics of JS or are a complete beginner, this FREE course on Sololearn can help you learn essential JavaScript in the least possible time - In DOM & Events
section in the course, we won't be using DOM concepts in this project, Events are important though. THIS BASIC COURSE DOESN'T TEACH ASYNCHRONOUS PROGRAMMING AND SOME OTHER IMPORTANT CONCEPTS, TO LEARN ADVANCED JS, REFER THIS TUTORIAL.