jtams / Rust-Game-Alerts-Discord-Bot

Discord Bot that alerts channel when someones is online/offline on Rust (game)
MIT License
3 stars 1 forks source link

Rust Game Discord Alerts

A bot that sends user's online status for the game Rust

Rust (the game not the language) alerts is a Discord bot that will send a message to a channel with information about what players are online. It uses the Battlemetrics API to get the player list and then checks if the user is online.

Tracker Message

Usage

Prerequisites

BOT_TOKEN=<YOUR_BOT_TOKEN, REQUIRED>
GUILD_ID=<YOUR_GUILD_ID, REQUIRED>
LOG_LEVEL=<LOG_LEVEL, optional> [default: INFO]
SAVE_FILE=<SAVE_FILE, optional> [default: ./savefile.json]

Method 1: Manual

go build
`./playertrackerbot`

I recommend running this as a service so it can run in the background and can auto restart in case of a crash.

Method 2: Docker

docker build -t rust-game-alerts-discord-bot .

or

docker buildx build -t rust-game-alerts-discord-bot .

To Run:

 docker run -d -v playertracker-data:/data --env-file .env -e SAVE_FILE=/data/savefile.json --name discord-playertracker rust-game-alerts-discord-bot

Note: After testing and verifying it starts up, it's recommended to add --restart unless-stopped to the docker run command after the -d to ensure the bot restarts if the container crashes.

Method 3: Docker Compose

Ensure that your .env file has a BOT_TOKEN and GUILD_ID set. LOG_LEVEL is optional, and SAVE_FILE is automatically set by the Docker file.

docker-compose up --build -d

Note: Despite what Docker says the restart policy will start spamming immedietly if the bot crashses on startup. So please ensure your BOT_TOKEN and GUILD_ID are correct before running the bot.

Features

Commands

/start <battle_metrics_server_id, optional>

Starts the tracker. Battle Metrics Server ID is requried to run the first time. If it is not provided, the bot will use the last server ID that was used.

/stop

Stops the tracker.

/users add <username(s)>

Adds user(s) to the tracker. Seperate multiple names with a comma. The name doesn't need to be exact and is not case sensitive. The search algorithm prioritizes exact matches first, then names that start with the inputted name, and finally names that contain the inputted name.

/users add-by-id

Similiar to the add command, but uses the Battle Metrics player ID instead of the player name. Useful when there are players with the same name.

/users remove <group, optional>

Removes user(s) from the tracker. If a group is provided, it will only remove from that group.

/users move

Moves a user to a different group.

/groups add

Adds a group to the tracker.

/groups remove

Removes a group from the tracker.

/groups location <location, optional>

Sets the location of the group. This gets added next to the group name in the tracker. Useful for noting the base location of a group. Running this command without location will remove the location.

/groups notes <notes, optional>

Sets the notes of the group. This gets added below the group name in the tracker. Useful for adding additional information about the group. Running this command without notes will remove the note.

/info user

Gets information about a user, including their BattleMetrics profile which will show the times they were on.

/info group

Gets information about a group.

To Do