This bot allows users to purchase a Discord role using Bitcoin Lightning payments through LNbits.
Users request an invoice via a slash command (configurable), and the bot automatically assigns the role once payment is confirmed.
- ✅ Dynamic slash‐command name (configured via command_name)
- ✅ Generates a Lightning invoice via LNbits
- ✅ Listens on LNbits WebSocket for paid invoices
- ✅ Automatically assigns a Discord role on payment
- ✅ Posts confirmations directly in your designated channel
- Ubuntu 24.04
- Python 3.10+
- A Discord Bot Token (from the Developer Portal)
- LNbits Wallet Invoice Key
- A running LNbits instance (e.g., Sats.Love)
- Go to: Discord Developer Portal
- Click New Application
- Go to OAuth2 > URL Generator
- Check these Scopes:
- ✅ bot
- ✅ applications.commands (for slash commands)
 
- Under Bot Permissions, check:
- ✅ Manage Roles
- ✅ Send Messages
- ✅ Embed Links
- ✅ Read Message History
 
- Copy & paste the generated link into your browser.
- Select your Discord server and click Authorize.
- Go to Discord Developer Portal.
- Select your bot application.
- Navigate to Botin the left sidebar.
- Scroll down to Privileged Gateway Intents.
- Enable the following:
- ✅ Presence Intent
- ✅ Server Members Intent
- ✅ Message Content Intent
 
- Click Save Changes.
- Go to Server Settings → Roles.
- Drag the bot’s role ABOVE the role it needs to assign.
- Ensure the bot has these permissions:
- ✅ Manage Roles
- ✅ Read Messages
- ✅ Send Messages
 
sudo apt update && sudo apt upgrade -y
sudo apt install python3 python3-pip python3-venv -ygit clone https://code.rustysats.com/saulteafarmer/discord-lnbits-bot
cd discord-lnbits-botpython3 -m venv venv
source venv/bin/activatepip install -r requirements.txtBefore configuring the bot, retrieve your Guild ID and Role ID.
- Open Discord → Go to User Settings (⚙️).
- Scroll down to Advanced → Enable Developer Mode.
- Right-click your server name (left sidebar) → Click Copy ID.
- Save this ID for later (guild_id).
- Open your Discord Server.
- Go to Server Settings → Roles.
- Right-click on the role you want to assign → Click Copy ID.
- Save this ID for later (role_id).
Edit the config.json file inside the bot directory:
sudo nano config.json{
  "discord_token": "YOUR_DISCORD_BOT_TOKEN",
  "guild_id": "YOUR_GUILD_ID",
  "role_id": "YOUR_ROLE_ID",
  "lnbits_url": "https://sats.love",
  "lnbits_api_key": "YOUR_INVOICE_READ_KEY",
  "channelid": "YOUR_CHANNELID_FOR_PURCHASE_ROOM",
  "price": 1000,
  "command_name": "support",
  "invoicemessage": "Invoice for your purchase."
}- discord_token→ Your bot token from Discord Developer Portal
- guild_id→ Your Discord server ID
- role_id→ The Discord role the bot will assign
- lnbits_url→ Base URL of your LNbits instance
- lnbits_api_key→ Invoice-only key from LNbits (- ⚠️ NOT an admin key)
- price→ Price in satoshis (e.g.,- 1000= 1000 sats)
- command_name→ Name of the command (default:- support)
- invoicemessage→ Message to be sent with invoice
- channelid→ Discord channel where invoices and confirmations post
python3 discord_lnbits_bot.pynohup python3 discord_lnbits_bot.py &🔹 To stop the bot:
pkill -f discord_lnbits_bot.pyThis project is open-source and free to use. Contributions welcome!