Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
A module for creating Discord bots using NestJS, based on Discord.js
This package uses the best of the Node.js 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 a fast and easy way of creating Discord bots and deep integration with your NestJS application.
Features
For questions and support, please use the Issues.
Node.js 18.0.0 or newer is required.
$ npm i necord discord.js
$ yarn add necord discord.js
$ pnpm add 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 { 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:
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:
FAQs
A module for creating Discord bots using NestJS, based on Discord.js
The npm package necord receives a total of 1,164 weekly downloads. As such, necord popularity was classified as popular.
We found that necord demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.