Discord Bot For Game Servers To Accept Bitcoin. Uses ZBD & Battlemetrics APIs, Written In Rust And Deployed With Shuttle.
This discord bot connects your game server to your Bitcoin lightning wallet via the Battlemetrics and ZBD APIs. Any server command can be put behind a lightning bitcoin paywall, enabling game server owners to monetize their server through the sale of server VIP perks, ingame items & more.
To get started:
- Clone this github repository to your local machine.
git clone https://github.com/stum0/zbd_discord_bot.git
- Create a
Secrets.toml
file and copy your ZBD, Battlemetrics & Discord bot secrets and your Battlemetrics server id:
DISCORD_TOKEN = 'discord'
ZBD_TOKEN = 'zbd'
SERVER_ID = 'id'
BM_TOKEN = 'bm token'
cargo install cargo-shuttle
- Login to shuttle.
cargo shuttle login
- Start your project with idle minutes set to 0 to keep it alive.
cargo shuttle project start --idle-minutes 0
- Deploy your discord bot.
cargo shuttle deploy --allow-dirty
In this example, at the time of writing, the only command provided is /mint
. It takes amount
and player
as inputs and responds with a lightning invoice
for the amount in satoshis (sats). The player name must match the ingame name of an online player. Once the invoice has been paid it will execute the ingame command giveitem blood amount player
for the game Rust; this gives the player the amount of blood corresponding to the amount of sats they have paid. This is a specific use case for the Orange Rust server.
Another useful server command that could be put behind a lightning bitcoin paywall is oxide.usergroup add user group
to sell access for players to VIP groups with ingame perks (e.g. permission to use plugins, queue skip etc). This would work for games that use the uMod plugin platform.
The Battlemetrics RCON supports 30+ games, including Battlebit, CS:GO, DayZ, Minecraft, Rust, Team Fortress 2 & Valheim. How to execute RCON commands via the Battlemetrics API.
https://api.battlemetrics.com/servers/$SERVER_ID/command
{
"data":{
"type":"rconCommand",
"attributes":{
"command":"raw",
"options":{
"raw":"$COMMAND_NAME"
}
}
}
}