Add beautiful, real-time Discord member count badges to your GitHub README
- ๐ Real-time Updates - Live member count with smart caching (5-minute intervals)
- ๐ฅ Multiple Badge Types - Total members, human-only, or bot-only counts
- ๐ก๏ธ Safe & Secure - Uses Discord API's
with_counts=true
for public access - โก Serverless Ready - Deploy to Vercel, Railway, Render, or any platform
- ๐จ Fully Customizable - Custom colors, labels, and scaling options
- ๐ฑ Mobile Responsive - Optimized playground interface for all devices
- ๐ฆ Zero Config - Just add your bot and start using
Preview | Description |
---|---|
![]() |
๐ฌ YouTube Demo Click the image to watch the full demo. |
![]() |
๐ Blog Post Read the blog for in-depth explanation. |
First, invite our bot to your Discord server:
- Go to your Discord server
- Navigate to Server Settings โ Engagement
- Enable Server Widget
- Copy your Server ID
Or follow this documentation
Replace YOUR_GUILD_ID
with your actual Discord server ID:
<!- All members -->
[](https://discord.gg/your-invite)
<!-- Bot members only -->
[](https://discord.gg/your-invite)
<!-- Total members (users + bots) -->
[](https://discord.gg/your-invite)
All endpoints support optional parameters for full customization:
color
(optional) - Hex color without # (default: 5865F2)label
(optional) - Custom text label (default: varies by endpoint)scale
(optional) - Size multiplier from 0.5 to 10.0 (default: 1)
<!-- Green badge with custom label and larger scale -->
[](https://discord.gg/your-invite)
<!-- Red bot count with custom styling -->
[](https://discord.gg/your-invite)
<!-- Purple total with community branding -->
[](https://discord.gg/your-invite)
Endpoint | Description | Default Label | Example |
---|---|---|---|
/api/discord-members |
All members | "Members" | |
/api/discord-bots |
Bot members only | "Bots" | |
/api/discord-total |
Total members with breakdown | "Total Users" |
guildId
orserverId
(required) - Your Discord server IDcolor
(optional) - Hex color without # (e.g., 5865F2, 27ae60, e74c3c)label
(optional) - Custom text label (e.g., "Users", "Community", "Members")scale
(optional) - Size multiplier from 0.5 to 10.0 (e.g., 1.2, 0.8, 2.0)- Response Format - SVG badge image
- Cache Duration - 5 minutes for optimal performance
Visit our Badge Playground to:
- ๐จ Customize Colors - Choose from presets or use custom hex colors
- ๐ Edit Labels - Create custom text for your badges
- ๐ Adjust Scale - Resize badges from 0.5x to 3x (up to 10x in URL)
- ๐ฑ Mobile Friendly - Fully responsive design for all devices
- โก Live Preview - See changes in real-time
- ๐ Copy & Paste - Get ready-to-use markdown code
Discord provides a public widget API that exposes limited server data like online member count:
https://discord.com/api/guilds/YOUR_GUILD_ID/widget.json
Example (for a server with ID 117924XXXXXX0559067
):
https://discord.com/api/guilds/117924XXXXXX0559067/widget.json
This API is useful for basic stats and online presence but only returns currently online users, not the full member list.
To enable this:
- Open your Discord server settings
- Go to the Widget section
- Toggle on Enable Server Widget
Note: this API is public and does not require authentication.
[](https://discord.gg/YOUR_INVITE_CODE)
discord-live-members-badge/
โโโ app/
โ โโโ api/
โ โ โโโ discord-members/
โ โ โ โโโ route.js
โ โ โโโ discord-bots/
โ โ โ โโโ route.js
โ โ โโโ discord-total/
โ โ โโโ route.js
โ โโโ documentation/
โ โ โโโ page.tsx
โ โโโ layout.tsx
โ โโโ page.tsx # Interactive playground
โ โโโ globals.css
โ โโโ not-found.tsx
โโโ components/
โ โโโ ui/ # shadcn/ui components
โโโ lib/
โโโ utils/
โ โโโ fetchAllMembers.js # Discord API utility
โโโ .env # Environment variables
โโโ ... (other config files)
- Node.js 18+
- Discord Bot Token
- Serverless platform account (Vercel, Railway, etc.)
Create a .env
file:
DISCORD_BOT_TOKEN=your_bot_token_here
# Clone the repository
git clone https://github.com/your-username/discord-live-members-badge.git
cd discord-live-members-badge
# Install dependencies
npm install
# Set up environment variables
cp .env
# Add your DISCORD_BOT_TOKEN
# Start development server
npm run dev
Test your badges locally:
http://localhost:3000/api/discord-members?guildId=YOUR_GUILD_ID&color=5865F2&label=Members&scale=1.2
If you want to use your own Discord bot:
- Go to Discord Developer Portal
- Create a new application
- Go to the Bot section
- Create a bot and copy the token
- Invite the bot to your server with these permissions:
- View Channels
- Manage Channels
The bot needs minimal permissions:
- View Channels (1024)
- Manage Channels (16)
Total permission integer: 1040
- Response Time: < 500ms average
- Cache Duration: 5 minutes per guild
- Rate Limiting: Built-in Discord API rate limit handling
- Uptime: 99.9% availability
- Mobile Optimized: Responsive design for all devices
The playground includes these popular color presets:
- Discord:
5865F2
(Default Discord blue) - Green:
27ae60
(Success/positive) - Blue:
3498db
(Information) - Red:
e74c3c
(Error/warning) - Orange:
f39c12
(Warning) - Purple:
9b59b6
(Creative) - Pink:
e91e63
(Accent) - Teal:
1abc9c
(Modern)
But yeah, you can add your custom color anytime.
The badge playground is fully optimized for mobile devices:
- Responsive Grid: Adapts to screen size (1 column on mobile, 2 on desktop)
- Touch-Friendly: Large buttons and inputs for mobile interaction
- Optimized Layout: Compact design for smaller screens
- Readable Text: Appropriate font sizes across devices
All endpoints return SVG images with:
- Content-Type:
image/svg+xml
- Cache-Control:
public, max-age=300
(5 minutes) - Error Handling: Returns error badge on failure
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- badge-maker for beautiful badge generation
- Discord for Developers community for inspiration
- shadcn/ui for the beautiful UI components
- Tailwind CSS for responsive styling
- LLMWare for allowing to show their Discord Server Stats.
- ๐ Bug Reports: GitHub Issues
- ๐ฌ Questions: GitHub Discussions
- ๐ง Email: rs4101976@gmail.com
- ๐ Documentation: Live Documentation
Made with โค๏ธ by Rohan Sharma, driven by dreams of Radhika Sharma ๐ซฐ
โญ Star this repo if you found it helpful!