Admin Bot

Table of Contents

  1. Introduction

  2. Features

  3. Requirements

  4. Installation

  5. Configuration

  6. Commands Reference

  7. Creating New Commands

  8. Creating New Events

  9. Creating Addons

  10. Exports and Integrations

  11. Logging System

  12. Troubleshooting

  13. Advanced Usage


Introduction

CAS AdminBot is a comprehensive Discord bot designed specifically for RedM server administration. It runs directly within your RedM server (no external hosting required) and provides powerful moderation, whitelisting, and utility features through Discord slash commands.

The bot is built on a modular architecture, making it extremely easy to extend with custom commands, events, and addons tailored to your server's needs.

Version Information

  • Current Version: 1.0.0

  • Minimum RedM Artifacts: Build 16565 or newer

  • Node.js Version: v12.13.0 (bundled with RedM)

  • Framework: discord.js (custom fork)


Features

Core Features

Standalone Resource - Runs directly in RedM, no external hosting needed ✅ Slash Commands - Modern Discord slash command interface with autocomplete ✅ Moderation Tools - Kick, ban, message, and manage players remotely ✅ Whitelist System - Role-based Discord whitelist enforcement ✅ Staff Chat - Bi-directional staff communication between Discord and in-game ✅ Auto ACE Permissions - Automatically grant server permissions based on Discord roles ✅ VorpCore Integration - Full support for VorpCore framework commands ✅ Webhook Logging - Log important events to Discord webhooks ✅ Bot Status Messages - Dynamic status updates showing player count ✅ Modular Architecture - Easy to extend with custom commands and features

Permission System

  • Role-based access control with four permission levels:

    • user - All Discord members

    • mod - Moderators

    • admin - Administrators

    • founder - Server owner/founders


Requirements

RedM Server Requirements

  • RedM artifacts build 4890 or higher (16565+ recommended)

  • cfx-server-data resource pack installed (specifically yarn at minimum)

  • Server running on Windows or Linux

Discord Requirements

  • Discord bot application with bot token

  • Discord server (guild) with manage server permissions

  • Both privileged intents enabled on Discord Developer Portal:

    • SERVER MEMBERS INTENT

    • MESSAGE CONTENT INTENT

Optional Requirements

  • VorpCore framework (for VORP-specific commands)


Installation

Step 1: Create Discord Bot Application

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

  2. Navigate to the Bot section in the left sidebar

  3. Click "Add Bot"

  4. CRITICAL: Under "Privileged Gateway Intents", enable:

    • SERVER MEMBERS INTENT

    • MESSAGE CONTENT INTENT

  5. Copy the bot token (you'll need this for configuration)

Step 2: Invite Bot to Your Discord Server

Replace YOUR-BOT-ID with your bot's Application ID and visit this URL:

Important: This link grants administrator permissions and slash command scope. If your bot is already in the server, you MUST run this link again to add the applications.commands scope.

Step 3: Install Resource

  1. Download/copy the cas_adminbot resource

  2. Place it in your RedM resources directory

  3. Ensure the folder is named exactly cas_adminbot (not cas_adminbot-main or anything else)

  4. Verify that [system]/[builders]/yarn/ exists in your resources

Step 4: Configure Server.cfg

Add the following to your server.cfg:

Step 5: Configure the Bot

Edit config.js and configure at minimum:

See Configuration for full configuration options.

Step 6: Start Your Server

Start your RedM server and check the console for:

If you see errors, check the Troubleshooting section.


Configuration

All configuration is done in config.js. You can also override these settings using convars in your server.cfg.

General Settings

Discord Bot Settings

Staff Chat Settings

When enabled, staff can use /staff <message> in-game and it forwards to Discord. Discord messages in the staff channel are sent to in-game staff.

Whitelist Settings

Players must have Discord open and one of these roles to join the server.

Slash Command Settings

These roles determine who can use which commands based on the command's role property.

Bot Status Messages

Cycles through status messages. Supports placeholders:

  • {servername} - Server name

  • {playercount} - Current player count

  • {invite} - Discord invite link

Auto ACE Permissions

Automatically grants FiveM ACE permissions to players when they join if they have the corresponding Discord role.

Webhook Logging

Other scripts can trigger webhook logs using the logging addon (see Addons).

Using Convars (Alternative Configuration)

Instead of editing config.js, you can set these in server.cfg:


Commands Reference

General Commands

Command
Description
Permission
Options

/help

Show all available commands with pagination

user

None

/onlinecount

Display current online player count

user

None

/server

Show detailed server and Discord statistics

user

None

Player Management Commands

Command
Description
Permission
Options

/players

List all online players with pagination

mod

None

/message

Send direct message to a player

mod

id (player ID), message (text)

/kick

Kick a player from the server

mod

id (player ID), message (optional reason)

/kickall

Kick all players from the server

admin

message (kick reason)

/kill

Kill a player in-game

admin

id (player ID)

/ban

Manage server bans

admin

Subcommands: • add: Ban a player (id, reason) • remove: Unban (license) • list: Show all bans

/announcement

Send server-wide announcement

mod

message (announcement text)

Context Menu Commands:

  • Right-click a Discord user → Apps → Check Online - See if they're currently in-game (requires mod role)

VorpCore Commands

These commands require VorpCore to be installed and loaded before cas_adminbot.

Command
Description
Permission
Subcommands/Options

/playerinfo

Get detailed player information

admin

id (player ID)

/heal

Heal a player to full health

admin

id (player ID)

/revive

Revive and fully heal a player

admin

id (player ID)

/currency

Manage player money/gold/rol

admin

Subcommands: • give: Add currency (id, type, amount) • take: Remove currency (id, type, amount)

/inventory

Manage player inventory

admin

Subcommands: • give: Add item (id, item, count) • take: Remove item (id, item, count) • inspect: View inventory (id)

/job

Manage player jobs

admin

Subcommands: • set: Assign job (id, job, label) • remove: Remove job (id) • view: View current job (id)

/permissions

Manage VORP permission groups

founder

Subcommands: • add: Grant permission (id, permission) • remove: Revoke permission (id) • view: View permissions (id)

Server Management Commands

Command
Description
Permission
Subcommands/Options

/resource

Manage server resources/scripts

founder

Subcommands: • start: Start a resource • stop: Stop a resource • ensure: Restart a resource • refresh: Reload all resources • list: List running resources • inspect: View resource info

/time

Set in-game time

admin

day, hour, minute, second, freeze (boolean)

/weather

Manage in-game weather

admin

Subcommands: • get: Show current weather • set: Change weather (preset, transition, freeze, permanentsnow) • forecast: View forecast

/whitelist

Configure whitelist settings

founder

Subcommands: • toggle: Enable/disable (enabled) • addrole: Add role to whitelist • removerole: Remove role from whitelist

Discord Utility Commands

Command
Description
Permission
Options

/embed

Send embedded messages to channels

founder

Subcommands: • simple: Quick embed (channel, message, title, image, thumbnail, footer, color) • complex: JSON embed (channel, json)

In-Game Commands

When staff chat is enabled:

Command
Description
Permission

/staff <message>

Send message to staff chat

ACE: cas_adminbot.staffchat

/stafftoggle

Toggle staff chat messages on/off

Discord staff role


Creating New Commands

The bot uses a modular command system. Each command is a separate .js file in the server/commands/ directory.

Command Structure

Create a new file server/commands/yourcommand.js:

Option Types

Type
Description
Example

STRING

Text input

User types "hello world"

INTEGER

Whole number

42, 100, -5

NUMBER

Decimal number

3.14, 2.5

BOOLEAN

True/false toggle

true, false

USER

Discord user picker

@Username

CHANNEL

Discord channel picker

#general

ROLE

Discord role picker

@Moderator

SUB_COMMAND

Creates subcommands

/parent subcommand

SUB_COMMAND_GROUP

Groups subcommands

/parent group subcommand

Subcommands Example

Accessing Bot Features in Commands

Context Menu Commands

Create a command that appears when right-clicking users or messages:

Reply Options

Best Practices

  1. Always validate input - Check if player IDs are valid before using them

  2. Use ephemeral responses for errors - Don't spam the channel with error messages

  3. Log important actions - Use client.utils.log for audit trails

  4. Handle errors gracefully - Use try/catch and provide helpful error messages

  5. Use defer for long operations - If command takes >3 seconds, defer the reply

  6. Check permissions - The role system handles this automatically, but double-check for sensitive operations


Creating New Events

Events respond to Discord.js events. Each event is a file in server/events/.

Event Structure

Create server/events/yourevent.js:

Common Discord.js Events

Event Name
When it Fires
Arguments

ready

Bot successfully connects

None

messageCreate

Message sent in Discord

message

messageDelete

Message deleted

message

messageUpdate

Message edited

oldMessage, newMessage

interactionCreate

Slash command or button pressed

interaction

guildMemberAdd

User joins Discord server

member

guildMemberRemove

User leaves Discord server

member

guildMemberUpdate

Member roles/nickname changes

oldMember, newMember

guildBanAdd

User banned from Discord

ban

guildBanRemove

User unbanned from Discord

ban

Example: Staff Chat Forwarding Event

Example: Auto-Role on Join

Example: Monitor Role Changes


Creating Addons

Addons are powerful extensions that can add entirely new functionality. They're classes instantiated at server startup.

Addon Structure

Create server/addons/youraddon.js:

Accessing Addon from Other Scripts

Once created, your addon is accessible at cas.youraddon:

Example: Logging Addon

The built-in log.js addon provides webhook logging:

Usage from other resources:


Exports and Integrations

CAS AdminBot exposes several exports for use by other resources.

Available Exports

isRolePresent(identifier, role)

Check if a player has a Discord role.

Parameters:

  • identifier - Player source, Discord ID, or member object

  • role - Single role ID (string) or array of role IDs

Returns: true if player has the role, false otherwise

getRoles(identifier)

Get all Discord roles for a player.

Returns: Array of role IDs

getName(identifier)

Get Discord display name for a player.

Returns: Discord display name or false

getDiscordId(identifier)

Get Discord ID from player source.

Returns: Discord ID (string) or false

Integration Examples

Lock Vehicle to Discord Role

Whitelist Check on Resource

Dynamic Permissions Based on Roles


Logging System

The bot includes a comprehensive logging utility accessible via client.utils.log.

Log Methods

Log Format

Cleaning Objects for Logging

Example Command with Logging


Troubleshooting

Bot Won't Start

Error: [TOKEN_INVALID]

  • Solution: Your bot token is invalid. Generate a new token in Discord Developer Portal and update config.js.

Error: [DISALLOWED_INTENTS]

  • Solution: You didn't enable the required intents. Go to Discord Developer Portal → Your App → Bot → Enable both SERVER MEMBERS INTENT and MESSAGE CONTENT INTENT.

Error: DiscordGuildId was not found

  • Solution: Double-check your Discord server ID in config.js. Right-click your server icon → Copy ID (you must have Developer Mode enabled in Discord).

Error: Missing Access when registering commands

  • Solution: Re-invite the bot using the invite URL with the applications.commands scope.

Bot is Online but Commands Don't Appear

  1. Check if slash commands are enabled:

  2. Re-invite the bot with the correct scope:

  3. Wait a few minutes - Discord can take time to register slash commands globally

  4. Check for command errors in server console - malformed commands won't register

Commands Are Registered But Don't Work

  1. Check role permissions - Make sure your Discord role IDs are correct in config.js

  2. Check bot permissions - Ensure bot has Administrator permission in Discord

  3. Check console logs - Look for errors when command is executed

  4. Try restarting the resource: restart cas_adminbot

Whitelist Not Working

  1. Verify whitelist is enabled:

  2. Check role IDs - Make sure DiscordWhitelistRoleIds contains the correct role IDs

  3. Ensure players have Discord open - RedM must be able to detect their Discord ID

  4. Check for errors in console when player connects

Staff Chat Not Working

  1. Verify staff chat is enabled:

  2. Check staff channel ID - Make sure DiscordStaffChannelId is correct

  3. Verify bot permissions - Bot needs Send Messages permission in the staff channel

  4. Check role IDs - Staff roles must be configured correctly

VorpCore Commands Don't Appear

  1. Ensure VorpCore is installed and running

  2. Check load order - VorpCore must be loaded before cas_adminbot in server.cfg:

  3. Check console - Look for "VorpCore found!" message

High CPU Usage / Lag

  1. Disable debug logs:

  2. Reduce bot status update frequency - Edit server/events/ready.js to increase interval

  3. Check for command loops - Make sure custom commands don't have infinite loops

Discord ID Not Detected

  1. Player must have Discord open before starting RedM

  2. Restart both Discord and RedM if issue persists

  3. Check Discord is running in background (not just web version)


Advanced Usage

Custom Localization

Edit or create new locale files in locales/ directory:

Set in config.js:

Dynamic Bot Status

Edit server/events/ready.js to customize how bot status updates:

Activity Types:

  • PLAYING - Playing {status}

  • WATCHING - Watching {status}

  • LISTENING - Listening to {status}

  • STREAMING - Streaming {status}

  • COMPETING - Competing in {status}

Pagination for Large Data

Use the built-in pagination system:

Custom Embed Builder

Secure Configuration with Environment Variables

Instead of hardcoding tokens in config.js, use convars in server.cfg:

Database Integration Example

If you want to track command usage in a database:

Webhooks for External Monitoring

Send important events to external services:

Rate Limiting Commands

Prevent command spam:


Support & Contributing

Getting Help

  • Discord Support: Join the official Discord

  • Documentation: This file and readme.md

  • Common Issues: Check Troubleshooting section

Reporting Bugs

When reporting bugs, include:

  1. RedM artifacts version

  2. Bot version

  3. Complete error message from console

  4. Steps to reproduce

  5. Your configuration (redact tokens/IDs)

Feature Requests

Have an idea? Open a ticket on Discord with:

  • Description of the feature

  • Use case / why it's needed

  • Example of how it would work


License

© 2025 by Brownyprod

This software (cas_adminbot) is licensed exclusively to the client.

Restrictions:

  • Reselling, redistribution, or sharing with any third party is strictly prohibited

  • The client is the sole authorized user of this software

  • Unauthorized use, copying, or distribution may result in legal action

If you want to use or modify this software for your own RedM server, please contact the author for a proper license.


Credits

  • Author: brownyprod

  • Framework: discord.js (custom fork)

  • Store: https://codeaftersex.com


End of Documentation

For the latest updates and announcements, join our Discord community at https://discord.gg/codeaftersex

Last updated