Files
Jiralite 319a73f8e6 build: Upgrade v14 dependencies (#11427)
* build: upgrade dependencies

* build: please Undici please

* build: regenerate file

* chore: fix docs by using bundler

* fix: revert upgrade for package

* build: fix versions
2026-02-24 23:18:54 +00:00
..
2023-05-03 02:14:22 +02:00
2022-10-13 22:20:36 +02:00
2023-05-03 02:14:22 +02:00
2023-08-24 06:43:23 +02:00
2024-09-02 22:26:25 +03:00
2023-09-30 00:42:43 +00:00


discord.js


Discord server npm version npm downloads Build status Last commit. Code coverage

Vercel Cloudflare Workers

About

@discordjs/brokers is a powerful set of message brokers

Installation

Node.js 20 or newer is required.

npm install @discordjs/brokers
yarn add @discordjs/brokers
pnpm add @discordjs/brokers

Example usage

pub sub

// publisher.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());

await broker.publish('test', 'Hello World!');
await broker.destroy();

// subscriber.js
import { PubSubRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new PubSubRedisBroker(new Redis());
broker.on('test', ({ data, ack }) => {
	console.log(data);
	void ack();
});

await broker.subscribe('subscribers', ['test']);

RPC

// caller.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());

console.log(await broker.call('testcall', 'Hello World!'));
await broker.destroy();

// responder.js
import { RPCRedisBroker } from '@discordjs/brokers';
import Redis from 'ioredis';

const broker = new RPCRedisBroker(new Redis());
broker.on('testcall', ({ data, ack, reply }) => {
	console.log('responder', data);
	void ack();
	void reply(`Echo: ${data}`);
});

await broker.subscribe('responders', ['testcall']);

Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the documentation.
See the contribution guide if you'd like to submit a PR.

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official discord.js Server.