Skip to main content

npm

Source

See the Plugins guide for how plugins from wolfstar-project/plugins fit alongside the core framework.

Description

A GatewayClient connects its gateway shards from a single process. @wolfstar/plugin-sharder spreads them across processes, cluster workers, worker threads, and machines. It implements the sharder RFC discordjs/discord.js#8084. A shard is what the manager spawns, and it can connect several gateway shards. The package knows nothing about Discord’s gateway. A shard runs any script that uses ShardClient, so it works with @wolfstar/plugin-gateway, @discordjs/ws, or another library.

Usage

The manager and the shards can share one script, because ShardClient.context is null in the manager:

Stars module

On framework 6.1 and later, list the ./module entry in modules in stars.config to add the package to the auto imports. It needs the optional @wolfstar/kit peer dependency, at ^0.2.0 || ^0.3.0.
The module registers no plugin and takes no options. It reserves the sharder key of stars.config for future options, so no other module can claim it. You still construct the ShardManager yourself.

Layout

"auto" needs the bot token (token, or DISCORD_TOKEN) or gatewayInformation.fetch. The manager fetches GET /gateway/bot once, caches it for gatewayInformation.ttl, and hands it to the shards.

Messages and requests

Messages are raw data, and a request is a message waiting for a reply: broadcastRequest replaces broadcastEval and fetchClientValues from discord.js. To share gateway dispatches between processes, pair it with @wolfstar/plugin-broker. version downloads license