anqder
v1.0.5
Published
New framework for easy create bot with discord.js library
Downloads
15
Readme
anqder
A small, lightweight core framework that makes building Discord bots with
discord.jseasier.
anqder is a minimalist core that accepts your existing Discord Client and makes common tasks — event registration,
interaction handling (buttons/modals), i18n plumbing, and logging — simple and repeatable. Point Anqder at your folders
and it will auto-load and wire up the pieces.
✨ Features
- Plug your existing
discord.jsClient — no forced client lifecycle. - Auto-load events, buttons, modals and commands from provided folders.
- Optional i18n integration support (
i18nextwith ICU pattern). - Flexible logger adapter support (use your own logger).
- TypeScript-ready with shipped
.d.tstypes. - Outputs both ESM and CJS builds.
🚀 Install
npm install anqder
# or
yarn add anqder🔧 Quick Start
import path from 'node:path'
import { Anqder } from 'anqder'
import { Logger } from 'winston' // optional, for example, you can use any logger instance
import { i18n } from './i18n' // optional
const anqder = new Anqder({
client: this.client,
i18n: i18n,
eventsPath: path.resolve(process.cwd(), './src/discord/events'),
modalsPath: path.resolve(process.cwd(), './src/discord/modals'),
buttonsPath: path.resolve(process.cwd(), './src/discord/buttons'),
commandsPath: path.resolve(process.cwd(), './src/discord/commands'),
mode: process.env.NODE_ENV,
logger: {
level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',
adapter: Logger.child({ label: 'Anqder' })
}
})
await anqder.init()After init() Anqder will:
- discover and register event handlers from
eventsPath, - register interaction handlers from
buttonsPathandmodalsPath, - optionally register commands from
commandsPath
📁 Recommended project structure
src/
discord/
events/
ready.ts
interactionCreate.ts
buttons/
pingButton.ts
modals/
feedbackModal.ts
commands/
ping.ts
package.json
index.tsPut one handler per file. Anqder will scan the configured folders and wire them to the client.
⚙️ Configuration (Types)
export interface AnqderOptions {
client: Client
i18n?: (language?: string) => TFunction
eventsPath?: string
modalsPath?: string
buttonsPath?: string
commandsPath?: string
mode?: 'development' | 'production' | 'dev' | 'prod' | 'develop' | string
logger?: { level?: LogLevel; adapter?: LoggerAdapter }
}
type LogLevel = 'error' | 'warn' | 'info' | 'debug'
interface LoggerAdapter {
error(...args: unknown[]): void
warn(...args: unknown[]): void
info(...args: unknown[]): void
debug(...args: unknown[]): void
}client— yourdiscord.jsClientinstance.i18n— optional factory returning aTFunctiontranslator for a given language.eventsPath,modalsPath,buttonsPath,commandsPath— folders to auto-load modules from.mode— environment mode; used for sensible defaults.logger— optional logger config: a logleveland anadaptercompatible withLoggerAdapter.
🧩 i18n
If you provide i18n as a factory (language?: string) => TFunction, handlers can call the returned function to
translate messages per user or guild locale.
Example:
const t = anqder.i18n?.('en')
t?.('welcome.message')🔌 Logger adapter
Anqder expects an adapter object exposing error, warn, info, debug. This keeps the internals logger-agnostic:
const loggerAdapter: LoggerAdapter = {
error: (...args) => pino.error(...args),
warn: (...args) => pino.warn(...args),
info: (...args) => pino.info(...args),
debug: (...args) => pino.debug(...args)
}🧾 License
This project is licensed under GPL-3.0-only. See the full license in LICENSE.
Note: GPL-3.0-only is a strong copyleft license. When you distribute software that links with or includes GPL-3.0-only code, your distribution must comply with GPL-3.0-only terms. Make sure GPL fits your intended distribution model.
📬 Questions?
Open an issue on GitHub: https://github.com/iamAlond/anqder
