Before you start, make sure that the Discord bot is switched off for the duration of the configuration.

Step 1: Recovering the Steam API key

  1. Go to https://steamcommunity.com/dev/apikey in your browser.

  2. Follow the instructions on this page to generate a Steam API key. Make sure you understand the conditions of use of the Steam API. In the space requesting a URL, you can indicate the IP of your game server.

  3. Copy the generated Steam API key.

  4. Open the "Config.json" file in the "Configuration Files" category of the configuration panel by clicking on the "Text Editor" button.

  5. Find the line containing "STEAM_API_KEY" and replace "STEAM_API_KEY" with the Steam API key you copied.

  6. Save the changes you have made to the "Config.json" file.

Step 2: Creating the Discord bot

  1. Go to https://discord.com/developers/applications and click on the "New Application" button.

  2. Choose a name for your application (the bot name can be changed later).

  3. Accept the terms and click on "Create".

  4. Go to the "OAuth2" -> "General" tab.

  5. In the "Redirects" section, click on "Add Redirect".

  6. You can put any URL in this field. In our case, we'll use "https://lydhosting.net".

  7. Go to the "URL Generator" tab.

  8. In the "Scopes" section, make sure you select "Bot" (this is sufficient).

  9. Do not tick anything in the "Bot permissions" section.

  10. Copy the link generated in the tab and open it in a new tab.

  11. Make sure you associate the bot with the right Discord server.

  12. The last important step is to go to the "Bot" tab and click on "Reset Token".

    • An API token looking like "MTExNDQ5OTg3MjEwMzEzNzQ0Nw.GETQ_j.8PaCS-Yfg0fCCZryVvj2bLcG0Az10WlVzcp9LE" will be displayed. You will need to copy this token.

Minor note: The 'Bot' tab also lets you change the avatar and name of the bot displayed on Discord.

Step 3: Finalising the configuration

  1. Paste the generated API token in place of the "Token" value in the "Config.json" file.

  2. Specify the IP address and Query Port of the target server to retrieve data on the number of players connected.

    • The IP address must be specified in the "Address" section.
    • The Query Port can be identified on your server administration page in the "Query Info" category.

  3. The final "Config.json" file should look like this:
{
  "UpdateTime": 30,
  "ServerInformation": [
    {
      "Name": "LH Bot2",
      "Address": "127.0.0.1:2303",
      "Token": "MTExNDQ5OTg3MjEwMzEzNzQ0Nw.GETQ_j.8PaCS-Yfg0fCCZryVvj2bLcG0Az10WlVzcp9LE",
      "UseNameAsLabel": false
    }
  ],
  "ApplicationTokens": {
    "SteamAPIKey": "E706715599E10Z0R2B257U8941233719",
    "BattleMetricsKey": "Here"
  }
}

To add a new server, you don't need to order a new Discord bot. Simply add a new entry to the "ServerInformation" section and create a new Discord application to generate a new token.

Here is an example of the code:

{
  "UpdateTime": 30,
  "ServerInformation": [
    {
      "Name": "LH Bot 1",
      "Address": "127.0.0.1:2303",
      "Token": "MTExNDQ5OTg3MjEwMzEzNzQ0Nw.GETQ_j.8PaCS-Yfg0fCCZryVvj2bLcG0Az10WlVzcp9LE",
      "UseNameAsLabel": false
    },
    {
      "Name": "LH Bot 2",
      "Address": "127.0.0.1:2403",
      "Token": "[The new token for your new Discord application]",
      "UseNameAsLabel": false
    }
  ],
  "ApplicationTokens": {
    "SteamAPIKey": "E706715599E10Z0R2B257U8941233719",
    "BattleMetricsKey": "Here"
  }
}

By following these steps, you will be able to configure your "Players Count" Discord bot to retrieve the number of players connected to your game server. Don't hesitate to contact us if you need any further assistance.

Ця відповідь Вам допомогла? 2 Користувачі, які знайшли це корисним (2 Голосів)