EmiliaB0nes / FiveMDiscordBot

FiveM server stats bot for Discord

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FiveM Discord Bot

FiveM server stats bot for Discord

Requirements

Config File

Name Description Example
botAddCommand First launch command !veryLongBotAdd
token Discord bot token xL89rF5RewAYyrWeChjQ.HpPg22e5ZtDscMyPxn.g4uJ9Jve
channelId Desired channel ID (Don't edit this field) 594936565819632525
postId (embed, postHistory) Post ID (Don't edit this field) 262003493384459751, 262003493384744995
dateCorrection Time offset for the graph 2
hoursShown (embed, postHistory) Set how many hours shown 24, 168
recurrence Recurrence in ms (1000 = 1 seconde) 60000
server Server ip and port 1.1.1.1:30100
serverName Server name for display My Server
thumbnail Server Thumbnail URL https://myserver.com/logo.png
chartLocation Desired Directory for the chart (On Web server) /var/www/html/fivem-charts
chartFileName Desired chart file name chart
chartFolderURL Public directory url for the chart https://myserver.com/fivem-graph
dataStorageTime Data storage time in minutes 1440
database Database Name history.sqlite
adMessageTitle Advertising Title My Custom Ad Title
adMessageText Advertising message Please vote for my server
footerMessage Footer Message Embed By FiveM Discord Bot

First Start

Get a Discord Bot Token

https://github.com/reactiflux/discord-irc/wiki/Creating-a-discord-bot-&-getting-a-token

Add the bot to your server

By editing this example link, you can add the bot to your server : https://discord.com/oauth2/authorize?scope=bot&permissions=2148001856&client_id=xxxxxxxxxxxxxxxxx

Install dependencies

  • Extract the release folder
  • Go into the folder
  • Execute the command: npm install

First Run

  • Add the bot to your server as described above

  • Before running the script, edit with your settings config.sample.json (except postId and channelId) and copy it as config.json

  • Execute: node index.js

  • In the desired Discord channel, type: !fivemdiscordbot

  • Execute again: node index.js

Move bot / Update

Move bot messages

If you want to move the bot on your server, you just have to delete in config.json: The channelId and postId data.

Then, run node index.js again In the desired Discord channel, type: !fivemdiscordbot Execute again: node index.js

Update

If it is indicated in the patch note that config.sample.json is updated. It is recommended to backup config.json, take the new config.sample.json and copy it as config.json and include the data of the old config.json (Except The channelId and postId data). The database will not be deleted.

Then, run node index.js again In the desired Discord channel, type: !fivemdiscordbot Execute again: node index.js

Automate the launch

Exemple using Ubuntu 20.04 LTS

Using GNU Screen and Cron

Don't use root or similar user!

In this example, I will execute the script at server startup with a cron job:

  • Execute: crontab -e

  • At the bottom of the file, add: @reboot /usr/bin/screen -dmS FiveMDiscordBot /usr/bin/node /path/to/script/index.js

  • To see the logs, execute: screen -r

    • If you get the error message: "There is no screen to be resumed.", It's because the script had an execution error, execute: node index.js to find the origin of the error.
  • To exit the logs, type ctrl + a + d

Known Issues

  • The chart is suddenly not updated anymore

    • There is too much data, decrease the dataStorageTime setting
    • If it doesn't work, The database is probably corrupted. To fix this problem, delete history.sqlite and copy/rename history.sqlite.template to history.sqlite
  • On Ubuntu 20.04 LTS (and in some other distributions), the Node.js version is too old

About

FiveM server stats bot for Discord

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%