πŸ”‘installation

Prerequisites

  • FiveM Server

  • MySQL Database (oxmysql)

  • Node.js installed on server

  • Discord Bot Token

  • screenshot-basic resource

Dependencies

Add to your server.cfg:

ensure oxmysql
ensure screenshot-basic
ensure sl-bot
1

Install Resource

  • Download and extract sl-bot to your resources folder

  • Place in resources/[sl]/sl-bot or your preferred location

2

Install Node.js Dependencies ( Optional if the server does not install it itself )

Navigate to the resource folder and install dependencies:

cd resources/[sl]/sl-bot
npm install
3

Create Discord Bot

  1. Go to https://discord.com/developers/applications

  2. Click "New Application" and give it a name

  3. Go to "Bot" section and click "Add Bot"

  4. Enable these Privileged Gateway Intents:

    • βœ… PRESENCE INTENT

    • βœ… SERVER MEMBERS INTENT

    • βœ… MESSAGE CONTENT INTENT

  5. Copy your Bot Token

  6. Go to OAuth2 β†’ URL Generator:

    • Scopes: bot

    • Bot Permissions: Administrator

  7. Copy the generated URL and invite bot to your server

4

Configure .env File

Create a .env file in the resource folder with the following content:

# Discord Bot Token (from Developer Portal)
TOKEN=YOUR_BOT_TOKEN_HERE

# Owner Role ID (full access to all commands)
OWNER_ROLE_ID=123456789012345678

# Admin Role ID (fallback for commands without specific roles)
ADMIN_ROLE_ID=123456789012345678

# Log Channel ID (optional)
LOG_CHANNEL_ID=123456789012345678

# Command Prefix (default: !)
PREFIX=!

How to get Role/Channel IDs:

  1. Enable Developer Mode in Discord (Settings β†’ App Settings β†’ Advanced β†’ Developer Mode)

  2. Right-click on a role or channel

  3. Click "Copy ID"

5

Configure Permissions

Edit shared/config.lua to set command permissions:

Config.CommandPermissions = {
    ['ban'] = { roles = { '123456789012345678' } },
    ['kick'] = { roles = { '123456789012345678', '987654321098765432' } },
    -- Add more...
}

Note: Empty roles = {} uses ADMIN_ROLE_ID from .env as fallback. Users with OWNER_ROLE_ID always have access to all commands.

6

Configure Webhooks

Edit editable/logs.lua to set webhook URLs:

LogsConfig.ScreenshotWebhook = 'https://discord.com/api/webhooks/...'

LogsConfig.Commands = {
    ban = { enabled = true, webhook = 'https://discord.com/api/webhooks/...', color = 0xFF0000, title = 'Player Banned' },
    -- Configure other commands...
}
7

Start Server

The script will automatically create database tables on first start:

  • sl_bans - Ban records

  • sl_warnings - Warning records

circle-check

❌ Common Issues (FAQ)

chevron-rightBot won't connecthashtag
  • Check if TOKEN in .env is correct

  • Verify Node.js dependencies are installed (npm install)

  • Check console for error messages

chevron-rightCommands not workinghashtag
  • Verify your Discord role is in the permission list

  • Check if you're using correct prefix (default: !)

  • Ensure bot has proper permissions in Discord

chevron-rightDatabase errorshashtag
  • Make sure oxmysql is started before sl-bot

  • Check MySQL connection settings

Last updated