mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
d20d01524b872549da501e21feec147ab204f397
Handlers. Redefined.
A complete, customizable, typesafe, & reactive framework for discord bots
Why?
- Most handlers don't support discord.js 14.7+
- Customizable commands
- Plug and play or customize to your liking
- Embraces reactive programming for consistent and reliable backend
- Customizable logger, error handling, and more
- Active development and growing community
👀 Quick Look
- Support for discord.js v14 and all interactions
- Hybrid commands
- Lightweight and customizable
- ESM, CommonJS and TypeScript support
- A powerful CLI and awesome community-made plugins
📜 Installation
npm install @sern/handler
yarn add @sern/handler
pnpm add @sern/handler
👶 Basic Usage
index.js (CommonJS)
// Import the discord.js Client and GatewayIntentBits
const { Client, GatewayIntentBits } = require('discord.js');
// Import Sern namespace
const { Sern, single } = require('@sern/handler');
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages
]
});
export const useContainer = Sern.makeDependencies({
build: root => root
.add({ '@sern/client': single(() => client) })
.upsert({ '@sern/logger': single(() => new DefaultLogging()) })
});
//View docs for all options
Sern.init({
defaultPrefix: '!', // removing defaultPrefix will shut down text commands
commands: 'src/commands',
// events: 'src/events' (optional),
containerConfig : {
get: useContainer
}
});
client.login("YOUR_BOT_TOKEN_HERE");
ping.js (CommonJS)
const { CommandType, commandModule } = require('@sern/handler');
exports.default = commandModule({
type: CommandType.Slash,
description: 'A ping pong command',
execute(ctx) {
ctx.reply('pong!');
}
});
🤖 Bots Using sern
- Community Bot, the community bot for our discord server.
- Vinci, the bot for Mara Turing.
- Bask, Listen your favorite artists on Discord.
- ava, A discord bot that plays KNGI and Gensokyo Radio.
- ALMA (WIP), Using AI to unleash the power in your server.
- Protector (WIP), Just a simple bot to help enhance a private minecraft server.
💻 CLI
It is highly encouraged to use the command line interface for your project. Don't forget to view it.
🔗 Links
👋 Contribute
- Read our contribution guidelines carefully
- Pull up on issues and report bugs
- All kinds of contributions are welcomed.
Languages
TypeScript
100%
