Skip to content

Build

Standalone or FiveM resource

Both targets produce a discord.js bot in TypeScript. The difference is where it runs, and that changes how it starts, how it is configured and what it can see.

The two targets side by side

Both Discord Bot Generator targets write discord.js 14.27.0 bots in TypeScript and run the same four checks. They differ in where the bot lives:

  • Runs on

    Standalone:Your PC, a VPS or a bot host
    FiveM resource:Inside your FiveM server
  • Starts with

    Standalone:npm start
    FiveM resource:ensure in server.cfg
  • Settings live in

    Standalone:.env
    FiveM resource:set lines in server.cfg
  • Commands registered by

    Standalone:npm run deploy
    FiveM resource:The resource itself, on every start
  • Build step

    Standalone:npm run build after npm install
    FiveM resource:None, dist/ is in the zip
  • Sees game data

    Standalone:No
    FiveM resource:Yes: players, identifiers, connections
  • Online while

    Standalone:Its process runs
    FiveM resource:Your server runs

Choose FiveM resource when the bot has to know or change something in the game. Choose Standalone for a community bot that has nothing to do with a game server, or when the bot must stay online while the game server restarts.

What a FiveM resource can do

A FiveM resource runs in the same process as your server scripts. It calls the server directly, with no extra connection and no extra hosting. Typical uses, all from the FiveM templates:

  • A voice channel named with the live player count, like Ingame: 24/64.
  • /players with names, server ids and pings.
  • A whitelist: players without a Discord role are refused on connect, with a message.
  • /kick, /ban and /msg from Discord, acting on the running server.

Players are matched to Discord through their discord: identifier. It exists only when the player runs the Discord app on the same PC, so tell players to keep Discord open when they join.

  1. 1. Files: every file of the project
  2. 2. Download: the same zip as in the checks panel

Why a FiveM resource looks different

The Node runtime inside FXServer has its own rules. The Project rules check enforces them, and they explain the files you see:

  • node_version '22'

    FXServer uses Node 16 by default, and discord.js 14 needs Node 18 or newer.
  • CommonJS, no top-level await

    The FiveM JavaScript runtime loads require(), not ES modules.
  • dependency 'yarn'

    The yarn resource installs discord.js into the resource folder when the server starts.
  • dist/server.js

    The compiled entry point. It ships in the zip, so you never run a build on the server.
  • Settings from convars

    The token and ids are read with GetConvar from set lines in server.cfg.
  • Clean shutdown

    The bot logs out when the resource stops, so a restart does not leave two sessions.

ESX, QBCore and other frameworks

By default a FiveM bot uses plain FiveM natives, which work on every server. When the bot should read jobs, money or items, name your framework and the resources in the request: "We run QBCore with ox_inventory; /giveitem should add the item through ox_inventory."

Need Lua instead?

A Discord bot is JavaScript in both targets. For in-game features in Lua, such as a menu or a job, use the AI Script Generator and let the bot talk to it through events or exports.