Changed README and created config fieldset definitions. Added screenshots

This commit is contained in:
Dennis Heinrich 2024-11-18 18:14:22 +01:00
parent cfc91801e4
commit 237f0213c3
3 changed files with 54 additions and 12 deletions

View file

@ -1,4 +1,22 @@
# Farming Simulator 25 - Discord Bot # Farming Simulator 25 - Discord Bot
This bot will post the server stats of a Farming Simulator 25 server to a Discord channel. The bot will post the server name, server password, server time, and the player count. The bot will update the server stats every x seconds (configurable).
![discord_embed.png](misc%2Fimages%2Fdiscord_embed.png)
The bot is written in Node.js and uses the [discord.js](https://discord.js.org/) library to interact with the Discord API. It
uses the XML-Feed from the Farming Simulator 25 server to get the server stats (you can find the feed URL in the web interface of the server).
![bot_terminal.png](misc%2Fimages%2Fbot_terminal.png)
# Requirements
- Node.js - if you want to run the bot without Docker
- NPM - if you want to run the bot without Docker
- Docker (optional) - if you want to run the bot in a Docker container
## Install the bot
## Create a Discord bot ## Create a Discord bot
1. Open the [Discord Developer Portal](https://discord.com/developers/applications) 1. Open the [Discord Developer Portal](https://discord.com/developers/applications)
@ -11,17 +29,41 @@
8. Click on `Copy` to copy the URL to install the bot to a guild 8. Click on `Copy` to copy the URL to install the bot to a guild
9. Your installation link url should look like this: `https://discord.com/oauth2/authorize?client_id=CLIENT_ID` 9. Your installation link url should look like this: `https://discord.com/oauth2/authorize?client_id=CLIENT_ID`
## Install the bot ## Configure the bot
1. Clone the repository 1. Clone the repository to your server
2. Move the `config.example.json` to `config.json` 2. Move the `config.example.json` to `config.json`
1. serverPassword: The password to the server 3. Fill in the required fields in the `config.json` file, do not delete fields, just leave them empty for default values
2. serverStatsUrl: The feed URL to the server stats (from the web interface from the server) 4. All fields with a `(*)` are required fields for the bot to work. The other fields are optional and can be left by default
3. serverMapUrl: The feed URL to the server map (from the web interface from the server)
4. guildId: The guild id where the bot should be installed | **- Key -** | **- Description -** |
5. channelId: The channel id where the bot should post the server stats |----------------------------------------------|---------------------------------------------------------------------------|
6. botToken: The bot token from the Discord Developer Portal | (*) application.serverPassword | The password to join the server (or leave empty) |
3. Add the bot token to the `config.json` | (*) application.serverStatsUrl | The feed URL to the server stats (from the web interface from the server) |
4. Add the prefix to the `config.json` | (*) application.serverMapUrl | The feed URL to the server map (from the web interface from the server) |
5. Run `npm install` | (*) application.updateIntervalSeconds | The interval in seconds to update the server stats |
6. Run `npm start` | (*) discord.guildId | The guild id where the bot should be installed |
| (*) discord.channelId | The channel id where the bot should post the server stats |
| (*) discord.botToken | The bot token from the Discord Developer Portal |
| translation.discordEmbed.title | The title of the Discord embed |
| translation.discordEmbed.descriptionOnline | The description when the server is online |
| translation.discordEmbed.descriptionOffline | The description when the server is offline |
| translation.discordEmbed.descriptionUnknown | The description when the server status is unknown |
| translation.discordEmbed.titleServerName | The title of the server name |
| translation.discordEmbed.titleServerPassword | The title of the server password |
| translation.discordEmbed.titleServerTime | The title of the server time |
| translation.discordEmbed.titlePlayerCount | The title of the player count |
| translation.discordEmbed.noPlayersOnline | The message when no players are online |
## Run inside a Docker container
1. Run `docker-compose up -d --build` in the root directory of the repository
2. The bot should be running now and posting the server stats to the Discord channel
### Run without Docker (Node.js)
1. Clone the repository to your server
2. Run `npm install`
3. Run `npm start`
4. The bot should be running now and posting the server stats to the Discord channel
5. If you close the terminal, the bot will stop running

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB