About
@discordjs/ws
is a powerful wrapper around Discord's gateway.
Installation
Node.js 16.9.0 or newer is required.
Optional packages
- zlib-sync for WebSocket data compression and inflation (
npm install zlib-sync
) - bufferutil for a much faster WebSocket connection (
npm install bufferutil
) - utf-8-validate in combination with
bufferutil
for much faster WebSocket processing (npm install utf-8-validate
)
Example usage
Specify shards
Specify worker_threads
You can also have the shards spawn in worker threads:
Note: By default, this will cause the workers to effectively only be responsible for the WebSocket connection, they simply pass up all the events back to the main process for the manager to emit. If you want to have the workers handle events as well, you can pass in a workerPath
option to the WorkerShardingStrategy
constructor:
And your worker.ts
file:
Links
- Website (source)
- Documentation
- Guide (source) See also the Update Guide, including updated and removed items in the library.
- discord.js Discord server
- Discord API Discord server
- GitHub
- npm
- Related libraries
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.