Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Client): allow custom numbers in intents option #1388

Merged
merged 7 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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