A Discord bot that generates single-use invite links for premium users and automatically assigns a role upon joining.
npm install- Go to Discord Developer Portal
- Create a new application
- Go to Bot → Add Bot
- Copy the Token (keep it secret!)
- Enable Server Members Intent under Privileged Gateway Intents
- Go to OAuth2 → URL Generator
- Select scopes:
bot - Select permissions:
Manage Server,Manage Roles,Send Messages - Copy the URL and invite the bot to your server
- Select scopes:
Right-click in Discord (with Developer Mode enabled in settings):
- Server ID: Right-click server → Copy Server ID
- Role ID: Server Settings → Roles → Right-click role → Copy Role ID
- Channel ID: Right-click channel → Copy Channel ID
cp .env.example .envEdit .env with your values:
DISCORD_TOKEN=your_bot_token
GUILD_ID=your_server_id
PREMIUM_ROLE_ID=your_premium_role_id
CHANNEL_ID=your_channel_id
API_SECRET=generate_a_random_secret
PORT=3000Development:
npm run devProduction:
npm run build
npm startcurl -X POST http://localhost:3000/api/create-invite \
-H "Content-Type: application/json" \
-d '{"secret": "your_api_secret", "userId": "user@email.com"}'Response:
{
"success": true,
"inviteUrl": "https://discord.gg/AbC123"
}curl http://localhost:3000/healthAfter payment via RevenueCat succeeds:
const response = await fetch('https://your-bot-host.com/api/create-invite', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
secret: 'your_api_secret',
userId: userEmail
})
});
const { inviteUrl } = await response.json();
// Show popup with inviteUrl- Go to pella.app
- Create account
- Upload your project
- Set environment variables
- Deploy!