discordjs-nextgen
v1.4.2
Published
Simple and powerful Discord bot library
Maintainers
Readme
discordjs-nextgen
Simple, fast, and modular Discord bot framework with both ESM and CommonJS support.
Why discordjs-nextgen?
- Fluent API for quick setup
- Dynamic and recursive file loading
- Hybrid command system for Prefix + Slash
- Middleware support
- Unified
Contextabstraction - Plugin system for modular extensions
Installation
npm install discordjs-nextgenQuick Start
import { App, Intents, Logger, cooldown } from 'discordjs-nextgen';
const app = new App({
intents: Intents.ALL,
});
app
.use(Logger({
colors: { info: 'cyan', error: 'red' },
}))
.use(cooldown(3))
.command({ folder: 'commands/hybrid' })
.button({ folder: 'buttons' })
.modal({ folder: 'modals' })
.select({ folder: 'selects' })
.prefix({ folder: 'commands/prefix', prefix: '!' })
.slash({ folder: 'commands/slash' })
.events('events')
.run('YOUR_DISCORD_TOKEN');Core Concepts
Hybrid Command
import { HybridCommand } from 'discordjs-nextgen';
const ping: HybridCommand = {
name: 'ping',
description: 'Measure latency',
aliases: ['p'],
run: async (ctx) => {
const delay = Date.now() - ctx.createdAt.getTime();
await ctx.reply(`Pong! Latency: **${delay}ms**`);
},
};
export default ping;Button Handler
import { ButtonHandler } from 'discordjs-nextgen';
const verifyButton: ButtonHandler = {
customId: 'verify_user',
run: async (ctx) => {
await ctx.reply({ content: 'Verified!', ephemeral: true });
},
};
export default verifyButton;Modal
import { Modal } from 'discordjs-nextgen';
const feedbackModal = Modal.create('feedback_form')
.title('Feedback')
.short('name', { label: 'Your name' })
.paragraph('comment', { label: 'Your comment', min: 10, max: 1000 })
.onSubmit(async (ctx) => {
await ctx.reply({
content: `Thanks ${ctx.values.name}! Your feedback was received.`,
ephemeral: true,
});
});
export default feedbackModal;Select Menu
import { Select } from 'discordjs-nextgen';
const colorSelect = Select.create('color_pick')
.placeholder('Choose a color')
.options([
{ label: 'Red', value: 'red' },
{ label: 'Blue', value: 'blue' },
])
.onSelect(async (ctx) => {
await ctx.reply(`Selected color: ${ctx.values.color_pick}`);
});
export default colorSelect;Context API
ctx normalizes both message and interaction flows:
ctx.userctx.guildctx.channelctx.reply(content | options)ctx.deferReply(ephemeral?)ctx.editReply(content | options)ctx.followUp(content | options)ctx.showModal(modal)ctx.valuesctx.argsctx.isInteractionctx.createdAt
Plugin System
app.use({
name: 'my-plugin',
setup: (bot) => {
bot.on('ready', (user) => {
console.log(`${user.tag} is ready`);
});
},
});API Highlights
App
.use(fn | plugin).command({ folder }).prefix({ folder, prefix }).slash({ folder, guildId? }).button({ folder }).button(customId, callback).select({ folder }).modal({ folder }).events(folder).run(token).login(token)
Helpers
Logger(options?)cooldown(seconds)EmbedBuilderButtonBuilderActionRowBuilderModalSelect
Notes
- Discord modals can only be opened from interactions, not regular message events.
- Prefix, slash, button, modal, and select flows can all share middleware.
License
MIT
