# HR Developer Bot - Complete Setup Guide

This guide will walk you through setting up the HR Developer Discord bot from scratch, including creating the bot on Discord, configuring the database, and running it on your server/hosting.

## Step 1: Discord Developer Portal Setup

1. Go to the [Discord Developer Portal](https://discord.com/developers/applications).
2. Click **New Application** in the top right corner.
3. Name your application "HR Developer" and click **Create**.
4. Go to the **Bot** tab on the left menu.
5. Under "Privileged Gateway Intents", turn ON all three intents:
   - **Presence Intent**
   - **Server Members Intent**
   - **Message Content Intent**
   - *(Click **Save Changes** at the bottom).*
6. Click **Reset Token** to generate your Bot Token. **Copy this token** and save it somewhere secure (you will need it for the `.env` file).

## Step 2: Invite the Bot to Your Server

1. In the Developer Portal, go to the **OAuth2 -> URL Generator** tab.
2. Under "Scopes", check the boxes for:
   - `bot`
   - `applications.commands`
3. Under "Bot Permissions", check **Administrator**. 
   *(Note: Administrator is easiest for setup, but if you want strict permissions, you need at minimum: Read/Send Messages, Manage Messages, Kick/Ban Members, Manage Channels, Manage Roles, Embed Links, Attach Files).*
4. Copy the generated URL at the bottom of the page.
5. Paste that URL into your browser, select your Discord server, and click **Authorize**.

## Step 3: Database Setup

1. Log in to your cPanel or VPS database manager (e.g., phpMyAdmin).
2. Create a new MySQL database (e.g., `hr_bot_db`).
3. Create a new MySQL user with a password and assign that user full privileges to your new database.
4. Open the `src/Database/schema.sql` file provided with the bot code.
5. In phpMyAdmin (or your preferred tool), select your new database, go to the **SQL** tab.
6. Copy and paste the entire contents of `schema.sql` into the text box and click **Go** to create all the necessary tables.

## Step 4: Configuring the Bot

1. On your hosting/VPS, navigate to the folder where you uploaded the bot files.
2. Find the file named `.env.example` and rename it to exactly `.env`.
3. Open the `.env` file and fill in your details:
   ```env
   # Your Discord Bot Token from Step 1
   BOT_TOKEN="YOUR_DISCORD_BOT_TOKEN_HERE"

   # Database Settings from Step 3
   DB_HOST="127.0.0.1"
   DB_PORT="3306"
   DB_NAME="your_database_name"
   DB_USER="your_database_user"
   DB_PASS="your_database_password"

   # (Optional) A channel ID where the bot can send startup/error logs
   LOG_CHANNEL_ID=""
   ```

## Step 5: Running the Bot

**Option A: Using a VPS (Recommended for 24/7 uptime)**
1. Connect to your VPS via SSH.
2. Navigate to your bot's directory: `cd /path/to/discord-bot`
3. Install dependencies: `composer install`
4. Use a process manager like `screen` or `pm2` so the bot stays online when you close the terminal.
   - Using screen:
     ```bash
     screen -S hrbot
     php bot.php
     ```
   - Press `Ctrl + A`, then `D` to detach and leave it running.

**Option B: Using cPanel (Shared/Web Hosting)**
*Note: Discord bots require a continuous WebSocket connection. Many shared hosting providers kill long-running PHP scripts. A VPS is strongly recommended.*
1. Open cPanel's **Terminal** feature.
2. Navigate to the bot folder (e.g., `cd public_html/discord-bot`).
3. Run `composer install`.
4. Run the bot in the background using `nohup`:
   ```bash
   nohup php bot.php > bot.log 2>&1 &
   ```

## Step 6: Initial Discord Setup

Once the bot is online (you should see it online in your server), you need to configure a few things using its slash commands:

1. **Set the Moderation Log Channel:** `/setlog channel:#mod-logs`
2. **Set the Welcome Channel:** `/setwelcome channel:#welcome`
3. **Set the Leave Channel:** `/setleave channel:#leaves`
4. **Set Auto-Role:** `/setautorole role:@Member` (The role to give when someone joins).
5. **Set Command Permissions:** By default, admin commands require the Administrator permission. You can allow specific roles to use commands using `/setrole command:play role:@DJ`.

Your bot is now fully set up and ready to use!
