Socket
Socket
Sign inDemoInstall

@spectacles/util

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spectacles/util

Spectacles utility methods


Version published
Maintainers
3
Created
Source

Spectacles Utils

Various utilities for interacting with Discord and using Spectacles.

Encoding/Decoding

encode and decode convenience functions for JSON de/serializing arbitrary data.

Permissions

A Permissions class with methods for dealing with Discord permissions.

  • static FLAGS: each individual Discord permission flag.
  • static ALL: every permission flag OR'd together
  • static NONE: 0
  • constructor(bitfield: number = Permissions.NONE)
  • add(perms: number): this: adds a bitfield to the permissions
  • remove(perms: number): this: removes permissions
  • has(perms: number): this: checks if permissions exist
  • apply(data: { guild: AvailableGuild, channel?: Channel, member?: GuildMember }): this: applies guild and optionally channel and member permissions to the bitfield. After this method, the bitfield will represent the final permissions for the given guild & channel and/or member with appropriate overrides. Operates in accordance with Discord recommendations.
  • readonly isAdmin: boolean: whether this bitfield contains the administrator flag
  • clone(): Permissions: create a new permissions instance from this bitfield
  • valueOf(): number: the bitfield
  • toJSON(): string[]: an array of readable strings representing the permissions in this bitfield

Snowflakes

A Snowflake class with methods for creating/inspecting Discord snowflakes. Requires BigInt support.

  • static EPOCH: number: the epoch to use for snowflakes (defaults to Discord's)
  • constructor(bin: bigint | string = 0n)
  • createdAt: Date: get/set when the snowflake was created
  • workerID: number: get/set the worker ID
  • processID: number: get/set the process ID
  • increment: number: get/set the increment
  • valueOf(): bigint: the raw snowflake

Keywords

FAQs

Package last updated on 30 Dec 2021

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