Non-internal sharding without using a full `Client` instance
Hi there, I own a large bot that I'm rewriting to be mostly HTTP-based. However, there are a number of features that require a gateway connection, so I am going to be running a discord.js application alongside it which will proxy events to the HTTP server (the latency introduced with this method is not a big concern).
I have written the gateway-enabled bot portion with
@discordjs/rest
and @discordjs/ws
in order to minimize ram usage. Unfortunately it seems that ShardingManager
requires you to use a full-fat Client
instance, which I don't want to do because of the limited cache reduction options - I do not need any cache, only an array of guild IDs for each shard, which I am currently tracking myself.
^ the ready with [...]
log there is from my WebSocketManager#on
WebSocketShardEvents.Ready
callback. The manager is ready but it seems like the parent ShardManager expects a Client
instead. Is there any way to maintain my desired philosophy? Thanks
discord.js
14.15.3
@discordjs/rest
2.3.0
@discordjs/ws
1.1.1
node 21.6.214 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!WebsocketManager doesn’t use Client
The point of the sub modules is to factor out d.js, not for it to depend on d.js
Yeah, but it doesn't seem like I can use ShardingManager without installing d.js
so I guess a better form of my question would be, how can I shard like this without installing d.js proper
Why not?
Do you get an error or smth?
because ShardingManager is only in d.js proper?
No
I couldn't find the submodule it was a member of, what's it from?
@discordjs/ws
The one I linked you to above
The ws sub package handles ws connections and shards
oh, is WebSocketManager able to shard non-internally? I thought I needed an external manager process
Oh right, it defaults to the worker threads strategy
You would need to make a strategy for spawning shards across processes. It is overridable in the options.buildStrategy
ok, thanks for the help
if I mark this as solved am I still able to come back later and post what I end up writing or will it be locked?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View