#Getting objects from client cache after sharding

21 messages · Page 1 of 1 (latest)

distant summit
#

So I am about to shard my bot... its not yet public but I want to make it shard compatible from the beginning.
My question is that... is getting stuff like guild object or user object from the cache or anything from the client cache in general if its different after sharding

sick geode
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

distant summit
#

discord.js and node

weak parrot
#

Depends on how you want to shard. Djs supports internal sharding (with several ws connections in the same process) that doesn’t affect how you work at all.
Traditional sharding (with several processes) needs you to get the information you need from other shards through IPC. Don‘t send full instances over that (since they get JSONified anyway) but only the data you actually need.

distant summit
#

which one is more efficient tbh

weak parrot
weak parrot
#

Once you need more than one server to handle the load you won‘t be able to use internal sharding anymore anyway

distant summit
distant summit
# weak parrot Sure you can…

alright ty... im new to sharding
so like can u show me an example of getting the information i need from other shards through IPC

cinder flareBOT
#

guide Sharding: Sending messages across shards
read more

distant summit
#

damn... complex

distant summit
#

and my bot is perfectly sharded ?

weak parrot
#

It will be perfectly sharded internally, yes

#

But please don’t use globalThis😳 or export the client like that. Let alone both

#

Virtually every payload of djs has a .client property, use that in your other files

distant summit
#

i'll do that thanks

distant summit
#

ok