[VORP/RSG] Nickname Discord

[VORP/RSG]  Nickname Discord

This item is free.

Add to Basket

# RSG Discord Nickname — Sync In-Game Name to Discord

Server-side resource for **RedM** that updates a player’s **nickname on your Discord server** when they log in with a character. The nickname is built from their in-game character data (e.g. citizen ID and full name) so staff can identify players in Discord.

## Features

- **Automatic update on login** — When a player loads (RSGCore character loaded), their Discord nickname in your guild is set to a configurable format.

- **Format placeholders** — Use `{citizenid}`, `{firstname}`, `{lastname}`, `{name}` (full name) in `Config.DiscordNickname.Format`.

- **Discord API** — Uses Discord Bot API (GET member, PATCH nickname). Skips the request if the nickname is already correct.

- **Length limit** — Nickname is trimmed to Discord’s max (configurable, default 32 characters).

- **Optional delay** — Configurable delay after player load before updating (so identifiers and charinfo are ready).

- **Debug** — Optional console messages to troubleshoot Discord ID, formatted nickname, and API errors.

## Requirements

- A **Discord Bot** with **Manage Nicknames** permission in your server.

- The bot’s **role** must be **above** the role of the members whose nicknames you want to change (Discord hierarchy).

- **Bot token** and **Guild (server) ID** set in `config.lua`.

- Players must have **Discord linked** to their FiveM/RedM identity (identifier `discord:...`).

## Dependencies

- **rsg-core** (uses `RSGCore:Server:PlayerLoaded` and player data).

## Configuration

Edit `config.lua`:

- **BotToken** — Your Discord bot token (Bot → Reset Token in Developer Portal).

- **GuildId** — Your Discord server ID (right‑click server → Copy ID; Developer Mode must be on).

- **Enabled** — Set to `false` to disable updates.

- **MaxNickLength** — Max nickname length (Discord limit 32).

- **Format** — String with placeholders: `{citizenid}`, `{firstname}`, `{lastname}`, `{name}`. Example: `'#{citizenid} {name}'` → `#ABC12345 John Doe`.

- **DelayMs** — Delay in milliseconds after player load before calling the Discord API.

- **Debug** — Set to `true` to print debug lines in the server console.

## Usage

1. Create a Discord bot, invite it to your server with **Manage Nicknames**, and put its role above member roles.

2. Set `BotToken` and `GuildId` in `config.lua` and adjust `Format` if needed.

3. When a player loads a character, the script gets their Discord ID from identifiers and their name from RSGCore; after the delay it sets their Discord server nickname to the formatted string.

4. If the nickname is already correct, no API call is made. On 403, check role hierarchy; on 404, the user is not in the server.

---

*RSG RedM Framework — Version 1.0.0*