Handlers. Redefined.

A complete, customizable, typesafe, & reactive framework for discord bots

NPM version NPM downloads License MIT docs.rs Lines of code
## Why? - Most handlers don't support discord.js 14.7+ - Customizable, composable 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](https://sern.dev/discord) ## 👀 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 ```sh npm install @sern/handler ``` ```sh yarn add @sern/handler ``` ```sh pnpm add @sern/handler ``` ## 👶 Basic Usage
ping.ts ```ts export default commandModule({ type: CommandType.Slash, //Installed plugin to publish to discord api and allow access to owners only. plugins: [publish(), ownerOnly()], description: 'A ping pong command', execute(ctx) { ctx.reply('Hello owner of the bot'); } }); ```
modal.ts ```ts export default commandModule({ type: CommandType.Modal, //Installed a plugin to make sure modal fields pass a validation. plugins : [ assertFields({ fields: { name: /^([^0-9]*)$/ }, failure: (errors, modal) => modal.reply('your submission did not pass the validations') }) ], execute : (modal) => { modal.reply('thanks for the submission!'); } }) ```
index.ts ```ts import { Client, GatewayIntentBits } from 'discord.js'; import { Sern, single, type Dependencies } from '@sern/handler'; //client has been declared previously interface MyDependencies extends Dependencies { '@sern/client': Singleton; } export const useContainer = Sern.makeDependencies({ build: root => root .add({ '@sern/client': single(() => client) }) }); //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"); ```
## 🤖 Bots Using sern - [Community Bot](https://github.com/sern-handler/sern-community), the community bot for our [discord server](https://sern.dev/discord). - [Vinci](https://github.com/SrIzan10/vinci), the bot for Mara Turing. - [Bask](https://github.com/baskbotml/bask), Listen your favorite artists on Discord. - [ava](https://github.com/SrIzan10/ava), A discord bot that plays KNGI and Gensokyo Radio. - [Murayama](https://github.com/murayamabot/murayama), :pepega: - [Protector (WIP)](https://github.com/needhamgary/Protector), Just a simple bot to help enhance a private minecraft server. ## 💻 CLI It is **highly encouraged** to use the [command line interface](https://github.com/sern-handler/cli) for your project. Don't forget to view it. ## 🔗 Links - [Official Documentation and Guide](https://sern.dev) - [Support Server](https://sern.dev/discord) ## 👋 Contribute - Read our contribution [guidelines](https://github.com/sern-handler/handler/blob/main/.github/CONTRIBUTING.md) carefully - Pull up on [issues](https://github.com/sern-handler/handler/issues) and report bugs - All kinds of contributions are welcomed.