Skip to main content


Necord Logo

🤖 A module for creating Discord bots using NestJS, based on Discord.js

Documentation ✨Source code 🪡Examples 🛠️Community 💬

NPM VersionNPM LicenseNPM DownloadsLast commit


This package uses the best of the NodeJS world under the hood. Discord.js is the most powerful library for creating bots and Nest.js is a progressive framework for creating well-architectured applications. This module provides fast and easy way for creating Discord bots and deep integration with your NestJS application.


  • 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.


Node.js 16.6.0 or newer is required.

$ npm install necord discord.js


Once the installation process is complete, we can import the NecordModule into the root AppModule:

import { NecordModule } from 'necord';
import { Module } from '@nestjs/common';
import { IntentsBitField } from 'discord.js';
import { AppUpdate } from './app.update';

imports: [
intents: [IntentsBitField.Flags.Guilds]
providers: [AppUpdate]
export class AppModule {}

Then create app.update.ts file and add On/Once decorators for handling Discord API events:

import { Injectable, Logger } from '@nestjs/common';
import { Context, On, Once, ContextOf } from 'necord';
import { Client } from 'discord.js';

export class AppUpdate {
private readonly logger = new Logger(;

public constructor(private readonly client: Client) {}

public onReady(@Context() [client]: ContextOf<'ready'>) {
this.logger.log(`Bot logged in as ${client.user.username}`);

public onWarn(@Context() [message]: ContextOf<'warn'>) {

Whenever you need to handle any event data, use the Context decorator.