# Installation

## Creating the bot application

1. While logged in, head to the [Discord Developer Portal](https://discordapp.com/developers/applications/).
2. Click the "New Application" button and name it the name of your bot.
3. Click the "Bot" button from the sidebar, and click "Add Bot".
4. Now that you have created a bot, you may change its username and icon. Click the "Click to Reveal Token" button or the "Copy" button to get your bot's token.
5. Rename `example.env` to `.env` All of your bot and client secrets will be stored here (don't share it with anybody!)
6. After renaming the file, add the token and client id to the **.env** file. It should end up looking something like this:

   ```properties
   DISCORD_TOKEN=YOUR_BOT_TOKEN
   CLIENT_ID=YOUR_BOT_CLIENT_ID
   DEPLOY_SLASH_COMMANDS=true
   ```

![Discord Applications](/files/-M9U2gJC1WYcuZKCj6oK)

## Gateway Intents

Some bots may require access to and process data from certain "privileged" parts of the API and you may need to enable Gateway Intents. You may enable them as shown below with the [Discord Developer Portal](https://discordapp.com/developers/applications/).

![](/files/-MOXtSvFcPB-P0fMWQTz)

## Dependencies

Dependencies are located in the package.json file and can be installed by running `npm i` while in the bot's directory. If you are missing your package.json file, please contact me directly.

<mark style="color:red;">**All of my current bots require a newer version of NodeJS (I've tested them on 18.20.3)!**</mark>

## Running the bot 24/7

### PM2

The following steps assume that you have NodeJS already installed.

1. Install a process manager such as [pm2](http://pm2.keymetrics.io/). We will use this to run the bot 24/7.
2. Navigate to wherever you unpacked the bot and proceed to the next step.
3. While in the bot's root directory, execute `npm i`. This will install the dependencies needed for the bot to run.

   The following steps are for pm2. If you are using another manager, please follow their docs.\
   If you don't already have a bot account, refer to the "Creating the bot application" section
4. Follow the pm2 docs to get the bot running 24/7

### Bot Host

Refer to your host's documentation on how to set up a Discord bot. The bot's main file/entry point is `dist/index.js`

## Inviting the bot to your server

After creating your Discord application and bot user, navigate to the OAuth2 page. Under scopes, click the "bot" checkbox <mark style="color:red;">**AND "Use Slash Commands."**</mark> After that, all you need to do is navigate to the generated URL and invite the bot to your server as normal.&#x20;

![OAuth2 Page](/files/-M9U3XI9XDwmTA9CG6rl)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bluedev.xyz/basics/installation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
