@spectacles/cache
TypeScript icon, indicating that this package has built-in type declarations

0.3.12 • Public • Published

Spectacles cache

Cache Discord objects in a cool way. Currently only supports Redis.

How to use

const { Client } = require('@spectacles/cache');
const Redis = require('ioredis');
const redis = new Redis();
const cache = new Client(redis); // client accepts an ioredis instance
(async () => {
  const role = await cache.guilds['some id'].roles.get('some other id');
  await cache.actions.guilds.upsert({ id: 'meme' }); // etc.
})();

Data structure

The internal data structures closely follows the format of data as returned from Discord. Every structure with an ID that is returned as an array will be converted to an object keyed by ID.

  • guilds
    • members
      • roles
      • presence
    • roles
    • emojis
    • voice_states - keyed by user ID
    • channels
  • channels
    • overwrites
  • users
const memberRoles = await cache.guilds['some id'].members['some id'].roles.get();
// memberRoles is an object { [roleID]: ...roleInfo }

Actions

All actions have 3 methods: set, upsert, and delete which behave as named. They are exposed on Client#actions.

  • guilds
  • channels
  • users
  • roles
  • members
  • emojis
  • voiceStates
cache.actions.guilds.upsert(guild);

Readme

Keywords

none

Package Sidebar

Install

npm i @spectacles/cache

Weekly Downloads

25

Version

0.3.12

License

ISC

Unpacked Size

40.8 kB

Total Files

32

Last publish

Collaborators

  • appellation
  • hackzzila
  • nomsy