clawdbot-workspace/discord-bot-automation-research.md

43 lines
1.3 KiB
Markdown

# Discord Bot Automation Research
## Goal
Automate the creation of Discord bot applications and tokens programmatically.
## Approaches
### 1. Discord REST API
Discord provides a REST API that can create applications/bots without browser automation.
**Key Endpoints:**
- `POST /applications/v2` - Create a new application
- `POST /applications/{application.id}/bot` - Add a bot user to an application
**Authentication:**
- User Account Token (from discord.com/login)
- Can be retrieved from browser local storage or by using Discord OAuth
### 2. Discord.js / Discord API Wrapper
Use Node.js libraries to interact with Discord's API:
- `@discordjs/rest`
- `discord-api-types`
### 3. Prerequisites
To create a bot application programmatically:
1. Discord user account token (NOT a bot token - need an account token)
2. The account must have 2FA enabled (Discord requirement for dev actions)
3. Proper headers for user agent and authorization
## Implementation Plan
1. Extract Discord user token from the Discord credentials
2. Use the Discord REST API to create a new application
3. Add a bot user to the application
4. Retrieve and return the bot token
5. Update clawdbot.json with the new bot token
6. Generate an OAuth2 invite link
## Next Steps
- Test the Discord REST API approach
- Build a Node.js script for bot creation
- Integrate into Clawdbot workflow