# Discord Monitor | Admin Tool

## 📖 Discord Channel Monitor - Installation Guide

### 🚀 Quick Start

Welcome to the complete installation guide for **Discord Channel Monitor**! This guide will walk you through every step needed to get your Discord monitoring system up and running.

***

### 📋 Prerequisites

Before we begin, make sure you have:

* ✅ **RedM** or **FiveM** server with admin access
* ✅ **Discord Server** where you want to monitor channels
* ✅ **Discord Account** with server management permissions
* ✅ **Tebex Purchase** completed and Keymaster access

***

### 🎯 Step 1: Download & Extract

#### 1.1 Download from Keymaster

1. Go to your [Keymaster Dashboard](https://keymaster.fivem.net/)
2. Find **cas-supchannel** in your purchased resources
3. Click **Download** to get the latest version
4. Extract the ZIP file to get the resource folder

#### 1.2 Install on Server

1. Copy the `cas-supchannel` folder to your server's `resources` directory
2.  The structure should look like:

    ```
    resources/
    └── cas-supchannel/
        ├── client/
        ├── server/
        ├── config/
        ├── locales/
        ├── web/
        └── fxmanifest.lua
    ```

***

### 🤖 Step 2: Discord Bot Setup

#### 2.1 Create Discord Application

1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
2. Click **"New Application"**
3. Enter a name (e.g., "Server Monitor Bot")
4. Click **"Create"**

#### 2.2 Create Bot User

1. In your application, go to **"Bot"** section
2. Click **"Add Bot"**
3. Confirm by clicking **"Yes, do it!"**
4. **Copy the Bot Token** (keep this secure!)

#### 2.3 Configure Bot Permissions

1. In the **"Bot"** section, enable these **Privileged Gateway Intents**:
   * ✅ **Presence Intent**
   * ✅ **Server Members Intent**
   * ✅ **Message Content Intent**

#### 2.4 Generate Invite Link

1. Go to **"OAuth2"** → **"URL Generator"**
2. Select **Scopes**:
   * ✅ `bot`
3. Select **Bot Permissions**:
   * ✅ `View Channels`
   * ✅ `Read Message History`
   * ✅ `Connect` (for voice channels)
   * ✅ `Use Voice Activity`
4. Copy the generated URL and open it in your browser
5. Select your Discord server and authorize the bot

***

### ⚙️ Step 3: Configuration

#### 3.1 Get Discord IDs

**Guild ID (Server ID):**

1. Enable **Developer Mode** in Discord (User Settings → Advanced → Developer Mode)
2. Right-click your server name
3. Click **"Copy ID"**

**Channel ID:**

1. Right-click the channel you want to monitor
2. Click **"Copy ID"**

**Your Discord ID (for admin access):**

1. Right-click your username
2. Click **"Copy ID"**

#### 3.2 Configure Server Settings

Edit `config/server-config.json`:

```json
{
  "discord": {
    "botToken": "YOUR_BOT_TOKEN_HERE",
    "guildId": "YOUR_GUILD_ID_HERE",
    "channelId": "YOUR_CHANNEL_ID_HERE",
    "updateInterval": 5000
  },
  "admins": [
    "steam:YOUR_STEAM_HEX_ID",
    "discord:YOUR_DISCORD_ID"
  ]
}
```

**Important Notes:**

* Replace `YOUR_BOT_TOKEN_HERE` with your Discord bot token
* Replace `YOUR_GUILD_ID_HERE` with your Discord server ID
* Replace `YOUR_CHANNEL_ID_HERE` with the channel you want to monitor
* Add your Steam Hex ID and Discord ID to the admins array

#### 3.3 Configure Client Settings

Edit `config/client-config.json`:

```json
{
  "ui": {
    "defaultPosition": {
      "x": 20,
      "y": 20
    },
    "defaultTheme": "dark",
    "defaultSounds": true,
    "maxUsers": 50
  },
  "sounds": {
    "userJoin": "sounds/user_join.ogg",
    "userLeave": "sounds/user_leave.ogg",
    "volume": 0.5
  },
  "defaultKeys": {
    "toggleMonitor": "F4",
    "openSettings": "F6"
  },
  "commands": {
    "dcMonitorCommand": "dc",
    "settingsCommand": "dcsettings",
    "hideCommand": "dchide"
  },
  "language": "en"
}
```

**Customization Options:**

* `defaultTheme`: `"light"` or `"dark"`
* `defaultSounds`: `true` or `false`
* `language`: `"en"` (English) or `"de"` (German)
* `maxUsers`: Maximum users to display (recommended: 50)

***

### 🔑 Step 4: Admin Setup

#### 4.1 Find Your Steam Hex ID

1. Join your server
2. Check server console or logs for your Steam ID
3. It should look like: `steam:110000100000000`

#### 4.2 Alternative: Use Discord ID

1. Right-click your username in Discord
2. Click **"Copy ID"**
3. Add it as: `discord:123456789012345678`

#### 4.3 Add Multiple Admins

```json
"admins": [
  "steam:110000100000000",
  "steam:110000100000001",
  "discord:123456789012345678",
  "discord:987654321098765432"
]
```

***

### 🚀 Step 5: Server Installation

#### 5.1 Add to server.cfg

Add this line to your `server.cfg`:

```
ensure cas-supchannel
```

#### 5.2 Start the Resource

1. **Option A**: Restart your server
2. **Option B**: Use console command: `restart cas-supchannel`

#### 5.3 Verify Installation

Check your server console for:

```
[Discord Monitor] Starting Discord Channel Monitor...
[Discord Bot] Connected as YourBotName#1234
[Discord Monitor] Discord Channel Monitor started successfully!
```

***

### 🎮 Step 6: Testing

#### 6.1 In-Game Commands

1. Join your server as an admin
2. Type `/dc` to toggle the monitor
3. Type `/dcsettings` to open settings
4. Type `/dchide` to minimize the window

#### 6.2 Verify Functionality

* ✅ Monitor window appears
* ✅ Discord users are listed
* ✅ Real-time updates work
* ✅ Settings panel opens
* ✅ Language switching works
* ✅ Minimize function works

***

### 🔧 Troubleshooting

#### Common Issues

**❌ "Bot not connected"**

**Solution:**

1. Check bot token in `server-config.json`
2. Verify bot is in your Discord server
3. Check bot permissions

**❌ "Channel not found"**

**Solution:**

1. Verify channel ID is correct
2. Check bot has access to the channel
3. Ensure bot permissions include "View Channels"

**❌ "Not authorized" message**

**Solution:**

1. Check your Steam/Discord ID in admin list
2. Verify ID format is correct
3. Restart resource after config changes

**❌ UI not showing**

**Solution:**

1. Check if you're added as admin
2. Try `/dc` command
3. Check browser console (F12) for errors

**❌ No sound notifications**

**Solution:**

1. Check sound files exist in `sounds/` folder
2. Verify sounds are enabled in settings
3. Check volume settings

#### Debug Mode

Enable debug logging by adding to your server console:

```
set discord_debug true
```

***

### 🎨 Customization

#### Language Support

The script supports English and German out of the box. To add more languages:

1. Create a new file in `locales/` (e.g., `fr.json`)
2. Copy the structure from `en.json`
3. Translate all strings
4. Update the language selector in settings

#### Theme Customization

You can customize the Wild West theme by modifying `web/styles.css`:

* Colors: Update CSS variables in `:root`
* Fonts: Change font families
* Animations: Modify keyframes and transitions

#### Sound Customization

Replace sound files in the `sounds/` folder:

* `user_join.ogg` - Played when someone joins
* `user_leave.ogg` - Played when someone leaves

***

### 📊 Performance Optimization

#### Update Intervals

Adjust `updateInterval` in server config:

* **5000ms** (5 seconds) - Default, good balance
* **3000ms** (3 seconds) - More responsive, higher load
* **10000ms** (10 seconds) - Less responsive, lower load

#### User Limits

Adjust `maxUsers` in client config:

* **50** - Default, good for most servers
* **25** - Better performance for lower-end clients
* **100** - For large communities (may impact performance)

***

### 🔒 Security Best Practices

#### Protect Your Bot Token

* ✅ Never share your bot token
* ✅ Keep `server-config.json` secure
* ✅ Use environment variables if possible
* ✅ Regenerate token if compromised

#### Admin Management

* ✅ Only add trusted admins
* ✅ Remove inactive admins
* ✅ Use both Steam and Discord IDs for redundancy

***

### 📞 Support

#### Getting Help

1. **Check this guide** - Most issues are covered here
2. **Discord Support** - Join our support server
3. **Tebex Messages** - Contact through your purchase
4. **Documentation** - Check our full docs

#### Before Contacting Support

Please provide:

* ✅ Server type (RedM/FiveM)
* ✅ Error messages from console
* ✅ Your configuration (without tokens)
* ✅ Steps to reproduce the issue

***

### 🎉 Congratulations!

You've successfully installed Discord Channel Monitor! Your server now has professional Discord integration with:

* 🎯 Real-time channel monitoring
* 🌍 Multi-language support
* 🎨 Beautiful Wild West themed UI
* 🔊 Sound notifications
* ⚙️ Extensive customization options

Enjoy your enhanced server experience! 🤠

***

**Need help? Join our Discord support server or contact us through Tebex!**
