Skip to content
This repository has been archived by the owner on May 11, 2024. It is now read-only.
/ cache Public archive

Discord State Cache

Notifications You must be signed in to change notification settings

Vexera/cache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@vexera/cache

Discord State Cache written in Typescript.


@vexera/cache is a library for processing Discord state events and updating an external cache accordingly.

Usage

const cache = new Cache({
  redis,
  caches: {
    channels: new MongoDB.ChannelCache(db.collection('channels')),
    guilds: new MongoDB.GuildCache(db.collection('guilds')),
    members: new MongoDB.MemberCache(db.collection('members')),
    users: new MongoDB.UserCache(db.collection('users')),
    voiceStates: new MongoDB.VoiceStateCache(db.collection('voiceStates')),
  },
  send(shardID, event) {
    shards.get(shardID).send(event);
  }
});

shards.on('event', (shardID, event) => {
  cache.receive({ ...event, shard_id: shardID });
});

See a larger, real example

Usage Notes

  • All events should be sent with a shard_id field, an integer of the shard id that the event came from.
  • A IDENTIFYING event should be sent when the shard has started identifying with the Discord gateway.

About

Discord State Cache

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published