nexcord-core
v0.0.2Nexcord basic project recipe
xnex install nexcord-core GitHub repo Nexcord Core
The starter recipe for Nexcord — a decorator-based Discord.js framework with built-in dependency injection, typed events, and JSX components.
Install
xnex install nexcord-core
The Nex CLI reads the recipe manifest, installs the required packages, and sets up the project structure for you.
Requires: Bun
What you get
src/
├── common/actions/
│ └── HelloButton.action.ts
├── components/
│ └── components.tsx
├── configs/
│ └── app.config.ts
├── events/
│ └── Init.events.ts
├── services/
│ ├── Logger.service.ts
│ └── Test.service.ts
└── index.ts
Plus .env.example, package.json, and tsconfig.json in your project root, already configured for Bun + TypeScript.
Quick start
- Copy
.env.exampleto.envand add your bot token:
TOKEN=your-discord-bot-token
- Start the bot:
bun run bot # start
bun run bot:dev # start with hot reload
- Send
helloin any channel the bot can see — it replies with a button. Click it for a little surprise.
How it works
Bootstrap — src/index.ts
NexCord.run starts the client and resolves whatever you list in inject, passing the instances into factory once they're ready.
NexCord.run(process.env.TOKEN!, {
factory: (loggerService: LoggerService, configService: ConfigService) => {
loggerService.log(configService.get('initMessage'))
},
inject: [LoggerService, ConfigService]
})
Services — src/services/
Any class marked @Service() becomes injectable.
@Service()
export class TestService {
test() {
return '[TEST SERVICE] -'
}
}
Services can depend on other services through the constructor — Nexcord resolves the graph for you:
@Service()
export class LoggerService {
constructor(private readonly testService: TestService) { }
log(...args: any[]) {
console.log(this.testService.test(), ...args)
}
}
Config — src/configs/
registerConfigWait registers a config value that depends on the client being ready. Nexcord waits for it before resolving.
registerConfigWait('initMessage', () => `${NexCord.client.user?.username} active`)
Events — src/events/
Group Discord.js event handlers in a class with @Listener(), then bind each one with @On(...). Handler arguments are typed automatically via DcEvents<'eventName'>.
@Listener()
class InitEvents {
@On('messageCreate')
async hello(...[message]: DcEvents<'messageCreate'>) {
if (message.content != 'hello') return
message.reply({
content: 'hello!',
components: [HelloButton({ userId: message.author.id })]
})
}
}
Components — src/components/
Build message components with JSX instead of chaining discord.js builders by hand.
export const HelloButton = ({ userId }: { userId: string }) => (
<row>
<button id={userId} label='Hello!' action={[HelloButtonAction]} />
</row>
)
Actions — src/common/actions/
Actions handle component interactions — buttons, menus, and the like. Same @Listener() decorator as events, but with a single execute method.
@Listener()
export class HelloButtonAction {
execute(i: ButtonInteraction) {
i.reply({ content: 'Hello XD', flags: 'Ephemeral' })
}
}
setup.files
Files that will be integrated into your project
- recipes
- nexcord-core
- README.md → recipes/nexcord-core
-
-
- src
- common
- actions
- HelloButton.action.ts → src/common/actions
-
-
- components
- components.tsx → src/components
-
- configs
- app.config.ts → src/configs
-
- events
- Init.events.ts → src/events
-
- services
- Logger.service.ts → src/services
- Test.service.ts → src/services
-
- index.ts → src
-
- .env.example → .
- package.json → .
- tsconfig.json → .
setup.scripts
Commands executed during recipe integration
These commands run automatically during integration — after your explicit approval via the Nex CLI.
- 1 Auto-run script
bun install discord.js @nexcord/core @nexcord/config @nexcord/tsx
nexconfig
Full recipe configuration
{
"name": "nexcord-core",
"version": "0.0.2",
"description": "Nexcord basic project recipe",
"keywords": [
"nexcord",
"nex",
"signorp",
"discord.js",
"discord-bots",
"framework"
],
"files": [
"src",
"recipes/nexcord-core/README.md",
".env.example",
"package.json",
"tsconfig.json"
],
"scripts": {
"bot": "bun run src/index"
},
"setup": {
"scripts": [
"bun install discord.js @nexcord/core @nexcord/config @nexcord/tsx"
],
"files": {
"src": {
"common": {
"actions": {
"HelloButton.action.ts": "src/common/actions"
}
},
"components": {
"components.tsx": "src/components"
},
"configs": {
"app.config.ts": "src/configs"
},
"events": {
"Init.events.ts": "src/events"
},
"index.ts": "src",
"services": {
"Logger.service.ts": "src/services",
"Test.service.ts": "src/services"
}
},
"recipes/nexcord-core/README.md": "recipes/nexcord-core",
".env.example": ".",
"package.json": ".",
"tsconfig.json": "."
}
}
}
You might also be interested in these
nexcord-log
Discord bot Message & Voice log bot recipe
nexcord-hello
Example Nexcord slash command that registers /hello and replies with an ephemeral greeting — a good starting point for building your own commands.
nestjs-basic-auth
NESTJS BASIC AUTH RECIPE
nestjs
NESTJS EMPTY TEMPLATE
nestjs-logging
NESTJS REQUEST LOGGING MIDDLEWARE RECIPE