π Universal Discord SDK & Framework - Enhanced TypeScript library for Discord bots and OAuth2 integration with modern features and complete API coverage.
Thank you for 135+ weekly downloads! π This "raw" library is growing fast thanks to our amazing community!
- π Critical Bug Fix - Fixed issue where bots wouldn't start due to missing Application ID in initialization
- π Documentation Update - Added information about Application ID requirement for bot initialization
- π³ Complete Docker Support - Multi-stage builds, Redis, PostgreSQL, Nginx, Prometheus monitoring
- π€ Enhanced Bot API - Full Discord.js-level functionality with improved command handling
- π§ Fixed Message Reading - Bots now properly read messages with prefixes like
!ping - π Improved Wiki - Comprehensive documentation following industry standards
- β‘ Performance Improvements - Better caching, rate limiting, and error handling
- π― New Bot Features - Guild management, role management, webhook support, and more!
- π€ Complete Bot Framework: Text & slash commands, interactive components, file uploads
- π Advanced OAuth2: Full PKCE implementation with comprehensive user data extraction
- ποΈ Interactive Components: Buttons, select menus, modals with easy API
- π File Handling: Upload and manage files with rich content
- π¨ Rich Embeds: Powerful embed builder with all Discord features
- π§ Middleware System: Advanced request processing and authentication
- π Full TypeScript: 200+ interfaces for complete Discord API coverage
- β‘ Modern Stack: TypeScript 5.7, ESLint 9, Vitest 2
- π³ Docker Ready: Complete containerization with monitoring and scaling
- π Discord.js Alternative: Comparable functionality with modern TypeScript design
npm install @locon213/unicordimport { UniCordBot, ButtonStyle } from '@locon213/unicord';
const bot = new UniCordBot({
token: process.env.DISCORD_TOKEN!,
intents: 513, // GUILDS + GUILD_MESSAGES
prefix: '!',
mentionPrefix: true,
handleAllMessages: true,
applicationId: process.env.DISCORD_CLIENT_ID, // Optional but recommended to prevent startup issues
});
// Text command with enhanced options
bot.command(
'ping',
async (ctx) => {
await ctx.reply('π Pong!');
},
{
aliases: ['p', 'pingpong'],
description: 'Check if the bot is alive',
category: 'Utility',
},
);
// Slash command with interactive components
bot.slash('hello', { description: 'Say hello with buttons' }, async (ctx) => {
const embed = bot
.createEmbed()
.setTitle('Hello World!')
.setDescription('Click a button below!')
.setColor(0x00ff00);
const button = bot.createButton(
'Click me!',
'hello_btn',
ButtonStyle.Primary,
);
const row = bot.createActionRow(button);
await ctx.reply({ embeds: [embed.toJSON()], components: [row] });
});
// Handle button interactions
bot.button('hello_btn', async (ctx) => {
await ctx.update({ content: 'Button clicked! β
', components: [] });
});
// Event handling
bot.onGuildMemberAdd(async (member) => {
console.log(`Welcome ${member.user?.username} to the server!`);
});
bot.onMessageCreate(async (message) => {
if (message.content.includes('hello')) {
await bot.sendMessage(message.channel_id, 'Hello there! π');
}
});
// Start the bot
bot.start();import { OAuth2, exchangeCodeForTokenNode } from '@locon213/unicord';
// Browser OAuth2
const oauth = new OAuth2({
clientId: 'your-client-id', // This is your Discord Application ID
redirectUri: 'http://localhost:3000/callback',
backendTokenURL: '/api/auth/discord',
});
// Different login scopes
await oauth.loginBasic(); // Basic user info
await oauth.loginFullProfile(); // User, email, guilds, connections
// Server-side token exchange
const result = await exchangeCodeForTokenNode({
clientId: process.env.DISCORD_CLIENT_ID!, // Your Discord Application ID
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
code: authCode,
redirectUri: redirectUri,
});# Build and run with Docker Compose
npm run docker:compose
# Or build manually
npm run docker:build
npm run docker:runOur Docker setup includes:
- Bot Service - Multi-stage optimized build
- Redis - Caching and session storage
- PostgreSQL - Persistent data storage
- Nginx - Reverse proxy with SSL
- Prometheus - Monitoring and metrics
Create a .env file:
DISCORD_TOKEN=your_bot_token
DISCORD_CLIENT_ID=your_client_id # Your Discord Application ID
DISCORD_CLIENT_SECRET=your_client_secret
REDIS_PASSWORD=unicord123
POSTGRES_USER=unicord
POSTGRES_PASSWORD=unicord123Complete documentation is available in the WIKI:
- Getting Started - Setup and basic usage
- Bot Commands - Command handling and components
- OAuth2 Integration - Authentication and user data
- API Reference - Complete API documentation
- Sharding - Scaling for large bots
- Docker Deployment - Container deployment guide
π View Changelog - See what's new in each version
git clone https://github.com/Locon213/UniCord.git
cd UniCord
npm install
npm run build
npm testCommands:
npm run build- Build the librarynpm run dev- Watch mode for developmentnpm run test- Run testsnpm run lint- Check code qualitynpm run docker:build- Build Docker imagenpm run docker:compose- Start with Docker Compose
- Multi-stage Docker builds for optimized images
- Redis caching for improved response times
- PostgreSQL for persistent data with proper indexing
- Nginx with rate limiting and SSL termination
- Prometheus monitoring for performance insights
- Health checks for all services
- Auto-scaling ready architecture
We welcome contributions! Please see our Contributing Guide for details.
- Weekly Downloads: 135+ (and growing!)
- GitHub Stars: Growing community
- TypeScript Coverage: 100%
- API Coverage: Discord.js equivalent
- Performance: Optimized for production
MIT Β© Locon213
Made with β€οΈ by the UniCord Community