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:
Cl00e9ment
2022-12-31 01:20:36 +01:00
committed by GitHub
parent d8dd197a93
commit 4ee00b6534

View File

@@ -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();
```