@djs-nest/core
Version:
Djs Nest Core Module provides functionality for handling discord events
98 lines (78 loc) • 3.06 kB
Markdown
<div align="center">
<h1>-nest/core</h1>
Core module which provides functionality for handling discord events.
<br/>
<p>
<a href="https://discord.gg/ZTapEzyD6G"><img src="https://img.shields.io/discord/1077051842615312496?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
<a href="https://www.npmjs.com/package/@djs-nest/core"><img src="https://img.shields.io/npm/v/@djs-nest/core.svg?maxAge=3600" alt="npm version" /></a>
<a href="https://www.npmjs.com/package/@djs-nest/core"><img src="https://img.shields.io/npm/dt/@djs-nest/core.svg?maxAge=3600" alt="npm downloads" /></a>
<a href="https://github.com/djs-nest/djs-nest/actions"><img src="https://github.com/djs-nest/djs-nest/actions/workflows/tests.yml/badge.svg" alt="Tests status" /></a>
<a href="https://codecov.io/gh/djs-nest/djs-nest" ><img src="https://codecov.io/gh/djs-nest/djs-nest/branch/main/graph/badge.svg?flag=core" alt="Code coverage" /></a>
</p>
</div>
---
## Installation
```bash
npm install -nest/core /core /ws
yarn install -nest/core /core /ws
pnpm install -nest/core /core /ws
```
## Example usage
### `forRoot` or `forRootAsync`
most common, autoconfigured DjsRestModule
Use this setup when you need both Discord Events and the REST client initialized and autoconfigured.
```ts
import { DjsCoreModule } from '@djs-nest/core';
import { Module } from '@nestjs/common';
export class MainModule {}
```
### `forExistingRest` or `forExistingRestAsync`
when externally configuring DjsRestModule
Use one of these options when you have externally configured the REST client.
```ts
import { DjsRestModule } from '@djs-nest/rest';
import { Module } from '@nestjs/common';
export class MainModule {}
```
### Listening to events
```ts
import { GatewayDispatchEvents } from '@discordjs/core';
import { ContextOf, DjsContext } from '@djs-nest/common';
import { On, Once } from '@djs-nest/core';
import { Injectable } from '@nestjs/common';
export class MyService {
onMessage( [message]: ContextOf<GatewayDispatchEvents.MessageCreate>) {
console.log('Message!');
}
onceReady( [ready]: ContextOf<GatewayDispatchEvents.Ready>) {
console.log('Ready!');
}
}
```
### Other Features
View the [documentation][documentation] for all features and examples
[documentation]: https://djs-nest.github.io/djs-nest/