Socket
Socket
Sign inDemoInstall

@spectacles/cache

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectacles/cache

Caching for Discord data.


Version published
Weekly downloads
11
increased by450%
Maintainers
3
Weekly downloads
 
Created
Source

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);

FAQs

Package last updated on 21 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc