This project allows you to export information from a Discord server (channels, roles, members, events) and display it on a web interface, with support for deployment to Render and integration with Vercel sites.
- Export Discord server data to JSON files
- Display server information on a web interface
- Real-time data about online members and active channels
- API endpoints for accessing Discord server data
- Automated export functionality via API
- Scheduled exports every 6 hours (configurable)
- CORS support for cross-origin requests
- Robust error handling and logging
- Deployment support for Render
- Integration with Vercel sites (including v0.dev)
- Python 3.8 or higher
- Discord Bot Token (with proper permissions)
- Discord server with administrator access
- Render account (for deployment)
- Go to the Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" tab and click "Add Bot"
- Under the "Privileged Gateway Intents" section, enable:
- Server Members Intent
- Message Content Intent
- Copy the bot token (you'll need this later)
- Go to the "OAuth2" > "URL Generator" tab
- Select the following scopes:
bot
applications.commands
- Select the following bot permissions:
- View Channels
- Send Messages
- Embed Links
- Attach Files
- Read Message History
- Use Application Commands
- Copy the generated URL and open it in your browser
- Select your server and authorize the bot
- Clone this repository
- Install the required packages:
pip install -r requirements.txt
- Create a
.env
file and add your Discord bot token:DISCORD_TOKEN=your_discord_token_here
- Start the bot and web server:
python main.py
- The web server will start on http://localhost:5000
- The Discord bot will connect to Discord
- Create a new Web Service on Render
- Connect your GitHub repository
- Set the following:
- Build Command:
pip install -r requirements.txt
- Start Command:
python main.py
- Build Command:
- Add the environment variable:
DISCORD_TOKEN=your_discord_token_here
- Set the Health Check Path to:
/api/health
- Deploy the service
- In your Vercel project, add an environment variable:
NEXT_PUBLIC_API_URL=https://your-render-service.onrender.com
- Use the provided React component in the
vercel-integration
directory - The component will automatically fetch and display Discord data
- For v0.dev sites, you can use the fetch code in your page.tsx/jsx files
!server_info
- Display basic server information!export
- Export comprehensive server data (admin only)!schedule
- Control the scheduled export task (admin only)!schedule status
- Check the status of scheduled exports!schedule start
- Start the scheduled export task!schedule stop
- Stop the scheduled export task!schedule interval:X
- Change the interval to X hours (e.g.,!schedule interval:12
)
The following API endpoints are available for integration with external applications:
/api/summary
- Get the latest export summary/api/channels
- Get the latest channels data/api/roles
- Get the latest roles data/api/members
- Get the latest members data/api/events
- Get the latest events data/api/all
- Get all data in a single response/api/realtime
- Get real-time data about online members and active channels/api/health
- Health check endpoint/api/trigger_export
- Trigger a new export (POST request)/api/create_directory
- Create the server_data directory if it doesn't exist/api/upload_file
- Upload a file to the server_data directory
main.py
- Main entry point that runs both the bot and web serversrc/
config.py
- Configuration settingscommands.py
- Discord bot commandsexporters.py
- Functions to export server dataweb_app.py
- Flask web application
server_data/
- Exported server data (JSON files)vercel-integration/
- Components and examples for Vercel integrationdebug_export.py
- Script to debug export functionalityfix_render_export.py
- Script to fix export issues on Renderfix_render_paths.py
- Script to fix file paths on Render
This script helps diagnose issues with the export functionality:
- Checks API health
- Triggers an export
- Verifies if data is available
This script helps fix export issues on Render:
- Creates export files manually using local data
- Uploads files to Render
- Checks if data is available through the API
This script fixes file path issues on Render:
- Creates export files with Linux-style paths
- Uploads files to Render
- Checks if data is available through the API
- Bot doesn't connect: Make sure your token is correct in the environment variables
- Missing permissions: Ensure the bot has the necessary permissions in your server
- No export data found: Check if the server_data directory exists and has proper permissions
- File path issues: Make sure file paths use forward slashes (/) on Render
- CORS errors: The API is configured to allow all origins, but if you're still having issues, check browser console for specific errors
- "Failed to fetch" in Vercel: Ensure your Render service is running and the NEXT_PUBLIC_API_URL is correct
-
Check API health:
curl https://your-render-service.onrender.com/api/health
-
Test CORS configuration:
curl -H "Origin: https://your-vercel-site.vercel.app" \ -H "Access-Control-Request-Method: GET" \ -H "Access-Control-Request-Headers: X-Requested-With" \ -X OPTIONS https://your-render-service.onrender.com/api/all
-
Fix export issues:
python fix_render_export.py
-
Fix file path issues:
python fix_render_paths.py
This project is licensed under the MIT License - see the LICENSE file for details.