@vexera/cache is a library for processing Discord state events and updating an external cache accordingly.
constcache=newCache({
redis,caches: {channels: newMongoDB.ChannelCache(db.collection('channels')),guilds: newMongoDB.GuildCache(db.collection('guilds')),members: newMongoDB.MemberCache(db.collection('members')),users: newMongoDB.UserCache(db.collection('users')),voiceStates: newMongoDB.VoiceStateCache(db.collection('voiceStates')),},send(shardID,event){shards.get(shardID).send(event);}});shards.on('event',(shardID,event)=>{cache.receive({ ...event,shard_id: shardID});});- All events should be sent with a
shard_idfield, an integer of the shard id that the event came from. - A
IDENTIFYINGevent should be sent when the shard has started identifying with the Discord gateway.