Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/necordjs/necord
🤖 A module for creating Discord bots using NestJS, based on Discord.js
https://github.com/necordjs/necord
bot bot-framework discord discord-bot discord-bot-api discordjs javascript nest nestjs nodejs typescript
Last synced: 4 days ago
JSON representation
🤖 A module for creating Discord bots using NestJS, based on Discord.js
- Host: GitHub
- URL: https://github.com/necordjs/necord
- Owner: necordjs
- License: mit
- Created: 2021-09-24T16:16:12.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2025-01-10T07:04:18.000Z (11 days ago)
- Last Synced: 2025-01-10T09:05:26.035Z (11 days ago)
- Topics: bot, bot-framework, discord, discord-bot, discord-bot-api, discordjs, javascript, nest, nestjs, nodejs, typescript
- Language: TypeScript
- Homepage: https://necord.org
- Size: 4.88 MB
- Stars: 387
- Watchers: 4
- Forks: 16
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
🤖 A module for creating Discord bots using NestJS, based on Discord.js
Documentation ✨ Source code 🪡 Examples 🛠️ Community 💬
## About
This package uses the best of the Node.js world under the hood.
[Discord.js](https://github.com/discordjs/discord.js) is the most powerful
library for creating bots and [Nest.js](https://github.com/nestjs) is a progressive framework for creating well-architectured applications.
This module provides a fast and easy way of creating Discord bots and deep integration with your NestJS application.**Features**
- Simple. Flexible. Easy to use.
- Ability to create custom decorators.
- Interact with Discord (Slash Commands, Context Menus, Message Components, Listeners).
- Full support of NestJS guards, interceptors, filters and pipes!For questions and support, please use
the [Issues](https://github.com/necordjs/necord/issues/new?assignees=&labels=question&template=question.yml).## Installation
**Node.js 18.0.0 or newer is required.**
```bash
$ npm i necord discord.js
$ yarn add necord discord.js
$ pnpm add necord discord.js
```## Usage
Once the installation process is complete, we can import the `NecordModule` into the root `AppModule`:
```typescript
import { NecordModule } from 'necord';
import { Module } from '@nestjs/common';
import { AppUpdate } from './app.update';@Module({
imports: [
NecordModule.forRoot({
token: 'DISCORD_BOT_TOKEN',
intents: ['Guilds', 'GuildMessages', 'DirectMessages']
})
],
providers: [AppUpdate]
})
export class AppModule {
}
```Then create `app.update.ts` file and add `On`/`Once` decorators for handling Discord API events:
```typescript
import { Injectable, Logger } from '@nestjs/common';
import { Context, On, Once, ContextOf } from 'necord';
import { Client } from 'discord.js';@Injectable()
export class AppUpdate {
private readonly logger = new Logger(AppUpdate.name);public constructor(private readonly client: Client) {
}
@Once('ready')
public onReady(@Context() [client]: ContextOf<'ready'>) {
this.logger.log(`Bot logged in as ${client.user.username}`);
}@On('warn')
public onWarn(@Context() [message]: ContextOf<'warn'>) {
this.logger.warn(message);
}
}
```Whenever you need to handle any event data, use the `Context` decorator.
If you want to fully dive into Necord, check out these resources:
* [Necord Wiki](https://necord.org) - Official documentation of Necord.
* [Nest JS](https://docs.nestjs.com) - A progressive framework for creating well-architectured applications.
* [Discord JS](https://discord.js.org) - The most powerful library for creating bots.
* [Discord API](https://discord.com/developers/docs) - Official documentation of Discord API.## Backers
## Stay in touch
* Author - [Alexey Filippov](https://t.me/socketsomeone)
* Twitter - [@SocketSomeone](https://twitter.com/SocketSomeone)## License
[MIT](https://github.com/necordjs/necord/blob/master/LICENSE) © [Alexey Filippov](https://github.com/SocketSomeone)