Overview • Requirements • Dependencies • Discord bot identity • Installation • Running the bot • Usage & Management • Credits
SquadPop is a Discord bot adapted to display the population of your favorite Squad servers on any Discord server. It does not require RCON access to the Squad server, and use the BattleMetrics API to get the information. You can display the population of multiple servers at the same time.
If you need help, contact me on Discord : nom4de
- Linux but can be adapted to Windows
- Git
- Node.js
- BattleMetrics API key
Discord.js
Powerful Node.js module that allows you to easily interact with the Discord API.
See on npm
axios
Promise based HTTP client for the browser and node.js.
See on npm
- Go to the Discord Developer Portal and create a new application.
- In the general information tab, enter the name of your bot (this is only the developer portal's name) and the description you want. You can also add a profile picture.
- Then go the the bot tab and add the name you want to display inside Discord. If you need a banner, this is also the place to do it.
- You can now reset the token and copy it in the
config.json
file as thebotToken
for each server. DO NOT SHARE THIS TOKEN WITH ANYONE (if you do, regenerate it). - Go to the OAuth2 tab and select
bot
in the OAuth2 URL Generator. Then select the permissions you want to give to your bot (I suggest giving it administrator permissions for your server). Select Guild Install as the integration type. You can generate a different link for each server you want to add the bot to. - Copy the generated link and paste it in your browser. You can now add your bot to your server if you are admin.
- Create as many bots as you have servers to display the population.
- Clone the repository (or download the zip) :
git clone https://github.com/Nicolas-Colombier/SquadPop.git
- Go to the bot directory :
cd SquadPop
- Install
npm
dependencies :
npm install
- Create a
config.json
file using theconfig.json.example
template :
cp config.json.example config.json
- Edit the
config.json
file and add your Discord bot token, your BattleMetrics API key, the server BattleMetrics ID and the server name :
server
: Each object is a server, if you have more then just add more object (be careful of the syntaxe). Each server can be on a different machine or user but need SSH access.botToken
: The token of your bot.battleMetricsToken
: Your BattleMetrics API key (you can get it on the BattleMetrics website).battleMetricsServerId
: The BattleMetrics ID of the server (can be found in the URL of the server page).
- Create a systemd service to run the bot (from this point requires sudo access):
nano /etc/systemd/system/squadpop.service
- Add the following content :
[Unit]
Description=Squad Pop
[Service]
Type=simple
User=name_of_your_linux_user
WorkingDirectory=/home/****/path_to_the_bot
ExecStart=/usr/bin/node /home/****/path_to_the_bot/main.js
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=name_of_your_linux_user
[Install]
WantedBy=multi-user.target
- Reload the service files to include the new service (requires sudo access) :
sudo systemctl daemon-reload
- Start the bot (requires sudo access) :
sudo systemctl start squadpop
- Check the status of the bot (requires sudo access) :
sudo systemctl status squadpop
- Enable the bot to start on boot (requires sudo access) :
sudo systemctl enable squadpop
To disable the bot to start on boot (requires sudo access) :
sudo systemctl disable squadpop
Stop the bot (requires sudo access) :
sudo systemctl stop squadpop
Take a look to the logs (requires sudo access) :
sudo journalctl -u squadpop
sudo journalctl -fu squadpop
- Foxinou - For the original idea and the first version of the bot