Skip to content

Commit

Permalink
feat(Client): allow custom numbers in intents option (#1388)
Browse files Browse the repository at this point in the history
Co-authored-by: Donovan Daniels <hewwo@yiff.rocks>
Co-authored-by: abalabahaha <hi@abal.moe>
  • Loading branch information
3 people committed Jun 29, 2022
1 parent bd58677 commit f886ebc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.d.ts
Expand Up @@ -386,7 +386,7 @@ declare namespace Eris {
firstShardID?: number;
getAllUsers?: boolean;
guildCreateTimeout?: number;
intents: number | IntentStrings[];
intents: number | (IntentStrings | number)[];
largeThreshold?: number;
lastShardID?: number;
/** @deprecated */
Expand Down
6 changes: 4 additions & 2 deletions lib/Client.js
Expand Up @@ -96,7 +96,7 @@ class Client extends EventEmitter {
* @arg {Number} [options.firstShardID=0] The ID of the first shard to run for this client
* @arg {Boolean} [options.getAllUsers=false] Get all the users in every guild. Ready time will be severely delayed
* @arg {Number} [options.guildCreateTimeout=2000] How long in milliseconds to wait for a GUILD_CREATE before "ready" is fired. Increase this value if you notice missing guilds
* @arg {Number | Array<String>} [options.intents] A list of intents, or raw bitmask value describing the intents to subscribe to. Some intents, like `guildPresences` and `guildMembers`, must be enabled on your application's page to be used. By default, all non-privileged intents are enabled.
* @arg {Number | Array<String|Number>} [options.intents] A list of [intent names](/Eris/docs/reference), pre-shifted intent numbers to add, or a raw bitmask value describing the intents to subscribe to. Some intents, like `guildPresences` and `guildMembers`, must be enabled on your application's page to be used. By default, all non-privileged intents are enabled.
* @arg {Number} [options.largeThreshold=250] The maximum number of offline users per guild during initial guild data transmission
* @arg {Number} [options.lastShardID=options.maxShards - 1] The ID of the last shard to run for this client
* @arg {Number} [options.latencyThreshold=30000] [DEPRECATED] The average request latency at which Eris will start emitting latency errors. This option has been moved under `options.rest`
Expand Down Expand Up @@ -179,7 +179,9 @@ class Client extends EventEmitter {
if(Array.isArray(this.options.intents)) {
let bitmask = 0;
for(const intent of this.options.intents) {
if(Constants.Intents[intent]) {
if(typeof intent === "number") {
bitmask |= intent;
} else if(Constants.Intents[intent]) {
bitmask |= Constants.Intents[intent];
} else {
this.emit("warn", `Unknown intent: ${intent}`);
Expand Down

0 comments on commit f886ebc

Please sign in to comment.