Download to your project directory:
git clone [email protected]:Ashpan/new_bot.git
or if you use HTTPS
git clone https://github.com/Ashpan/new_bot.git
Make sure you have nodejs and npm installed
Then run npm install
Now to create and invite a bot to a server go through the following steps.
- Go to the Discord developer portal
- Select new application and call it whatever you want to
- Go to the
bot
tab and hit reset token to get your bot token. You will need this later, so make sure to note this down. - Next go to the
OAuth2
tab and you should see aClient ID
, note this down as well as you will need it too. - Now to invite the bot to a server go to
URL Generator
and selectapplication.commands
andbot
, then in the second set of checkboxes, select the permissions you want to give to the bot. - Finally copy the generated URL and open it to invite the bot to your desired server.
Now in the project root create a file called config.json with the following contents
{
"TOKEN": "TOKEN",
"CLIENT_ID": "CLIENT_ID",
"GUILD_IDS": ["SERVER_IDS"],
"DB_USERNAME": "MONGO_USERNAME",
"DB_PASSWORD": "MONGO_PASSWORD",
"DB_CLUSTER": "MONGO_CLUSTER"
}
Make sure to replace TOKEN
with your bot token, CLIENT_ID
with the bot application client id, and the SERVER_IDS
with the ID of the servers the bot will be used in.
If you want to include multiple it should look like ["SERVER_1_ID", "SERVER_2_ID", "SERVER_3_ID"]
.
MONGO_USERNAME
with the username of the mongoDB database you will be using and MONGO_PASSWORD
with the password for the database. You can create it using MongoDB Atlas. MONGO_CLUSTER
with the cluster url like cluster0.xyz.mongo.net
.
To run the bot now you need to first sync any and all commands.
You can do this by: npm run sync
Then the bot is ready to be run with: npm run dev
While the bot is running it should auto-refresh when you make changes to *.js
files but you can also refresh it by typing rs
in the terminal and hitting enter.