buddy

node MVC discord bot
Log | Files | Refs | README

Intents.js (2113B)


      1 'use strict';
      2 const BitField = require('./BitField');
      3 
      4 /**
      5  * Data structure that makes it easy to calculate intents.
      6  * @extends {BitField}
      7  */
      8 class Intents extends BitField {}
      9 
     10 /**
     11  * @name Intents
     12  * @kind constructor
     13  * @memberof Intents
     14  * @param {IntentsResolvable} [bits=0] Bit(s) to read from
     15  */
     16 
     17 /**
     18  * Data that can be resolved to give a permission number. This can be:
     19  * * A string (see {@link Intents.FLAGS})
     20  * * An intents flag
     21  * * An instance of Intents
     22  * * An array of IntentsResolvable
     23  * @typedef {string|number|Intents|IntentsResolvable[]} IntentsResolvable
     24  */
     25 
     26 /**
     27  * Numeric websocket intents. All available properties:
     28  * * `GUILDS`
     29  * * `GUILD_MEMBERS`
     30  * * `GUILD_BANS`
     31  * * `GUILD_EMOJIS`
     32  * * `GUILD_INTEGRATIONS`
     33  * * `GUILD_WEBHOOKS`
     34  * * `GUILD_INVITES`
     35  * * `GUILD_VOICE_STATES`
     36  * * `GUILD_PRESENCES`
     37  * * `GUILD_MESSAGES`
     38  * * `GUILD_MESSAGE_REACTIONS`
     39  * * `GUILD_MESSAGE_TYPING`
     40  * * `DIRECT_MESSAGES`
     41  * * `DIRECT_MESSAGE_REACTIONS`
     42  * * `DIRECT_MESSAGE_TYPING`
     43  * @type {Object}
     44  * @see {@link https://discordapp.com/developers/docs/topics/gateway#list-of-intents}
     45  */
     46 Intents.FLAGS = {
     47   GUILDS: 1 << 0,
     48   GUILD_MEMBERS: 1 << 1,
     49   GUILD_BANS: 1 << 2,
     50   GUILD_EMOJIS: 1 << 3,
     51   GUILD_INTEGRATIONS: 1 << 4,
     52   GUILD_WEBHOOKS: 1 << 5,
     53   GUILD_INVITES: 1 << 6,
     54   GUILD_VOICE_STATES: 1 << 7,
     55   GUILD_PRESENCES: 1 << 8,
     56   GUILD_MESSAGES: 1 << 9,
     57   GUILD_MESSAGE_REACTIONS: 1 << 10,
     58   GUILD_MESSAGE_TYPING: 1 << 11,
     59   DIRECT_MESSAGES: 1 << 12,
     60   DIRECT_MESSAGE_REACTIONS: 1 << 13,
     61   DIRECT_MESSAGE_TYPING: 1 << 14,
     62 };
     63 
     64 /**
     65  * Bitfield representing all privileged intents
     66  * @type {number}
     67  * @see {@link https://discordapp.com/developers/docs/topics/gateway#privileged-intents}
     68  */
     69 Intents.PRIVILEGED = Intents.FLAGS.GUILD_MEMBERS | Intents.FLAGS.GUILD_PRESENCES;
     70 
     71 /**
     72  * Bitfield representing all intents combined
     73  * @type {number}
     74  */
     75 Intents.ALL = Object.values(Intents.FLAGS).reduce((acc, p) => acc | p, 0);
     76 
     77 /**
     78  * Bitfield representing all non-privileged intents
     79  * @type {number}
     80  */
     81 Intents.NON_PRIVILEGED = Intents.ALL & ~Intents.PRIVILEGED;
     82 
     83 module.exports = Intents;