mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
docs: updated @discordjs/ws README.md to include optional packages (#8973)
* docs: updated ws's readme to include optional packages - added optional packages to the README.md - added an example on how to add a listener to the ws manager, in the README.md * docs: changed "addEventListener" to "on" in ws's readme changed "addEventListener" to "on" in @discord.js/ws README.md Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -30,10 +30,16 @@ yarn add @discordjs/ws
|
||||
pnpm add @discordjs/ws
|
||||
```
|
||||
|
||||
### Optional packages
|
||||
|
||||
- [zlib-sync](https://www.npmjs.com/package/zlib-sync) for WebSocket data compression and inflation (`npm install zlib-sync`)
|
||||
- [bufferutil](https://www.npmjs.com/package/bufferutil) for a much faster WebSocket connection (`npm install bufferutil`)
|
||||
- [utf-8-validate](https://www.npmjs.com/package/utf-8-validate) in combination with `bufferutil` for much faster WebSocket processing (`npm install utf-8-validate`)
|
||||
|
||||
## Example usage
|
||||
|
||||
```ts
|
||||
import { WebSocketManager } from '@discordjs/ws';
|
||||
import { WebSocketManager, WebSocketShardEvents } from '@discordjs/ws';
|
||||
import { REST } from '@discordjs/rest';
|
||||
|
||||
const rest = new REST().setToken(process.env.DISCORD_TOKEN);
|
||||
@@ -44,6 +50,10 @@ const manager = new WebSocketManager({
|
||||
rest,
|
||||
});
|
||||
|
||||
manager.on(WebSocketShardEvents.Dispatch, (event) => {
|
||||
// Process gateway events here.
|
||||
});
|
||||
|
||||
await manager.connect();
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user