This project includes a Discord announcement bridge for a FiveM loading screen.
The bot fetches messages from a Discord channel and writes them to shared/announcements.json, which the loading screen reads.
server/bot.jsconnects to Discordserver/api.jsexposes/announcementsif you need a web APIshared/announcements.jsonis the JSON file used by the loading screenshared/config.jsis the client-side loading screen config
Before setting this up, make sure you have:
- Node.js 18+ and npm
- A Discord bot account and a server where the bot can read messages
- Access to the announcement channel ID and server ID in Discord
The server-side bot dependencies are managed in server/package.json and can be installed with:
cd server
npm installThis project is designed to work with a Discord bot that you create in the Discord Developer Portal. No database or external token storage is required.
You only need to:
- create a Discord bot
- enable the required bot intents
- get the bot token, server (guild) ID, and channel ID
- set those values in
server/config.jsonorserver/.env - run
npm installandnpm startfromserver/
- Go to the Discord Developer Portal: https://discord.com/developers/applications
- Create a new application.
- Open the
Bottab and clickAdd Bot. - Copy the bot token.
- Under
Privileged Gateway Intents, enable:Message Content Intent
- Open the
OAuth2tab and go toURL Generator. - Select
botscope. - Grant at least these bot permissions:
Read Messages/View ChannelsRead Message HistorySend Messages(optional for testing)
- Copy the generated invite URL and open it.
- Invite the bot to your server.
Make sure the bot also has access to the announcement channel itself with:
View ChannelRead Message HistoryRead Messages
- Enable Developer Mode in Discord:
User Settings→Advanced→Developer Mode
- Right-click your server icon and choose
Copy IDforguildId. - Right-click the announcement channel and choose
Copy IDforchannelId.
Open server/config.json and fill in the values:
{
"token": "YOUR_DISCORD_BOT_TOKEN",
"guildId": "YOUR_SERVER_ID",
"channelId": "ANNOUNCEMENT_CHANNEL_ID",
"announcementLimit": 4,
"outputFile": "../shared/announcements.json",
"apiPort": 3010
}The bot also supports environment variables if you want to keep secrets out of source files.
You can set these values in a .env file inside server/:
DISCORD_BOT_TOKEN=your_token_here
GUILD_ID=your_guild_id_here
CHANNEL_ID=your_channel_id_here
ANNOUNCEMENT_LIMIT=4
OUTPUT_FILE=../shared/announcements.jsonA sample file is available at server/.env.example.
token: your bot token from Discord Developer PortalguildId: server ID where the announcements channel existschannelId: ID of the channel with announcement messagesannouncementLimit: how many recent messages to fetchoutputFile: file path used by the bot to save announcement JSONapiPort: optional port forserver/api.js
previewMode: trueinshared/config.jsis intended for browser preview and local design/testing.- In preview mode, the loading screen uses simulated progress and sample announcement data.
- For actual FiveM server testing, set
previewMode: falseso the UI receives real progress events fromclient/client.luaand live announcements fromshared/announcements.json.
From the server directory, run:
cd server
npm install
npm startThe bot will log in and update shared/announcements.json on the configured interval.
If you want to serve announcements over HTTP, run:
node api.jsThen visit http://localhost:3010/announcements to confirm it returns JSON.
- If the loading screen shows no announcements, make sure
shared/announcements.jsonexists and contains valid JSON. - If the bot does not update the file, confirm the bot is running and that your Discord token, guild ID, and channel ID are correct.
- If the bot cannot read the channel, verify the bot has
View Channel,Read Message History, andRead Messagespermissions in that channel. - If the bot is online but still not reading messages, check that the bot is actually invited to the server and that the channel ID is the announcement channel, not a different one.
- If you changed the bot configuration, restart the bot so it picks up the new settings.
- The loading screen expects
shared/announcements.jsonto exist and be valid JSON. - You can store
DISCORD_BOT_TOKEN,GUILD_ID, andCHANNEL_IDin a.envfile instead ofserver/config.json. - Keep your bot token secret.
