Socket
Socket
Sign inDemoInstall

eris

Package Overview
Dependencies
6
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.16.1 to 0.17.0

lib/structures/TextVoiceChannel.js

1

index.js

@@ -53,2 +53,3 @@ "use strict";

Eris.TextChannel = require("./lib/structures/TextChannel");
Eris.TextVoiceChannel = require("./lib/structures/TextVoiceChannel");
Eris.ThreadChannel = require("./lib/structures/ThreadChannel");

@@ -55,0 +56,0 @@ Eris.ThreadMember = require("./lib/structures/ThreadMember");

8

lib/Constants.js

@@ -384,3 +384,4 @@ "use strict";

sendMessagesInThreads: 1n << 38n,
startEmbeddedActivities: 1n << 39n
startEmbeddedActivities: 1n << 39n,
moderateMembers: 1n << 40n
};

@@ -398,3 +399,5 @@ Permissions.allGuild = Permissions.kickMembers

| Permissions.manageWebhooks
| Permissions.manageEmojisAndStickers;
| Permissions.manageEmojisAndStickers
| Permissions.manageEvents
| Permissions.moderateMembers;
Permissions.allText = Permissions.createInstantInvite

@@ -415,2 +418,3 @@ | Permissions.manageChannels

| Permissions.useApplicationCommands
| Permissions.manageThreads
| Permissions.createPublicThreads

@@ -417,0 +421,0 @@ | Permissions.createPrivateThreads

@@ -41,2 +41,6 @@ "use strict";

get headers() {
return this.response.headers;
}
get name() {

@@ -43,0 +47,0 @@ return this.constructor.name;

@@ -45,2 +45,6 @@ "use strict";

get headers() {
return this.response.headers;
}
get name() {

@@ -47,0 +51,0 @@ return `${this.constructor.name} [${this.code}]`;

@@ -13,17 +13,24 @@ "use strict";

this.connectQueue = [];
this.lastConnect = 0;
this.connectTimeout = null;
this.concurrency = null;
this.buckets = new Map();
}
connect(shard) {
if(shard.sessionID || (this.lastConnect <= Date.now() - 5000 && !this.find((shard) => shard.connecting))) {
shard.connect();
this.lastConnect = Date.now() + 7500;
} else {
this.connectQueue.push(shard);
this.tryConnect();
async connect(shard) {
// fetch max_concurrency if needed
if(!this.concurrency) {
const gateway = await this._client.getBotGateway();
if(gateway.session_start_limit && gateway.session_start_limit.max_concurrency) {
this.concurrency = gateway.session_start_limit.max_concurrency;
} else {
this.concurrency = 1;
}
}
this.connectQueue.push(shard);
this.tryConnect();
}
spawn(id) {
async spawn(id) {
let shard = this.get(id);

@@ -95,3 +102,3 @@ if(!shard) {

if(shard.status === "disconnected") {
this.connect(shard);
return this.connect(shard);
}

@@ -101,18 +108,46 @@ }

tryConnect() {
if(this.connectQueue.length > 0) {
if(this.lastConnect <= Date.now() - 5000) {
const shard = this.connectQueue.shift();
shard.connect();
this.lastConnect = Date.now() + 7500;
} else if(!this.connectTimeout) {
this.connectTimeout = setTimeout(() => {
this.connectTimeout = null;
this.tryConnect();
}, 1000);
// nothing in queue
if(this.connectQueue.length === 0) {
return;
}
// loop over the connectQueue
for(const shard of this.connectQueue) {
// find the bucket for our shard
const rateLimitKey = (shard.id % this.concurrency) || 0;
const lastConnect = this.buckets.get(rateLimitKey) || 0;
// has enough time passed since the last connect for this bucket (5s/bucket)?
// alternatively if we have a sessionID, we can skip this check
if(!shard.sessionID && Date.now() - lastConnect < 5000) {
continue;
}
// Are there any connecting shards in the same bucket we should wait on?
if(this.some((s) => s.connecting && ((s.id % this.concurrency) || 0) === rateLimitKey)) {
continue;
}
// connect the shard
shard.connect();
this.buckets.set(rateLimitKey, Date.now());
// remove the shard from the queue
const index = this.connectQueue.findIndex((s) => s.id === shard.id);
this.connectQueue.splice(index, 1);
}
// set the next timeout if we have more shards to connect
if(!this.connectTimeout && this.connectQueue.length > 0) {
this.connectTimeout = setTimeout(() => {
this.connectTimeout = null;
this.tryConnect();
}, 500);
}
}
_readyPacketCB() {
this.lastConnect = Date.now();
_readyPacketCB(shardID) {
const rateLimitKey = (shardID % this.concurrency) || 0;
this.buckets.set(rateLimitKey, Date.now());
this.tryConnect();

@@ -119,0 +154,0 @@ }

@@ -276,3 +276,3 @@ "use strict";

const retryAfter = parseInt(resp.headers["x-ratelimit-reset-after"] || resp.headers["retry-after"]) * 1000;
const retryAfter = Number(resp.headers["x-ratelimit-reset-after"] || resp.headers["retry-after"]) * 1000;
if(retryAfter >= 0) {

@@ -303,8 +303,17 @@ if(resp.headers["x-ratelimit-global"]) {

const content = typeof body === "object" ? `${body.content} ` : "";
this._client.emit("debug", `${resp.headers["x-ratelimit-global"] ? "Global" : "Unexpected"} 429 (╯°□°)╯︵ ┻━┻: ${response}\n${content} ${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${this.ratelimits[route].reset} (${this.ratelimits[route].reset - now}ms left)`);
if(retryAfter) {
let delay = retryAfter;
if(resp.headers["x-ratelimit-scope"] === "shared") {
try {
delay = JSON.parse(response).retry_after * 1000;
} catch(err) {
reject(err);
return;
}
}
this._client.emit("debug", `${resp.headers["x-ratelimit-global"] ? "Global" : "Unexpected"} 429 (╯°□°)╯︵ ┻━┻: ${response}\n${content} ${now} ${route} ${resp.statusCode}: ${latency}ms (${this.latencyRef.latency}ms avg) | ${this.ratelimits[route].remaining}/${this.ratelimits[route].limit} left | Reset ${delay} (${this.ratelimits[route].reset - now}ms left) | Scope ${resp.headers["x-ratelimit-scope"]}`);
if(delay) {
setTimeout(() => {
cb();
this.request(method, url, auth, body, file, route, true).then(resolve).catch(reject);
}, retryAfter);
}, delay);
return;

@@ -311,0 +320,0 @@ } else {

@@ -7,3 +7,3 @@ "use strict";

/**
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, NewsChannel, PrivateChannel, TextChannel, and VoiceChannel.
* Represents a channel. You also probably want to look at CategoryChannel, GroupChannel, NewsChannel, PrivateChannel, TextChannel, and TextVoiceChannel.
* @prop {Client} client The client that initialized the channel

@@ -35,3 +35,3 @@ * @prop {Number} createdAt Timestamp of the channel's creation

case ChannelTypes.GUILD_VOICE: {
return new VoiceChannel(data, client);
return new TextVoiceChannel(data, client);
}

@@ -97,2 +97,2 @@ case ChannelTypes.GROUP_DM: {

const TextChannel = require("./TextChannel");
const VoiceChannel = require("./VoiceChannel");
const TextVoiceChannel = require("./TextVoiceChannel");

@@ -220,3 +220,3 @@ "use strict";

if(this.acknowledged === true) {
return this.createFollowup(content);
return this.createFollowup(content, file);
}

@@ -223,0 +223,0 @@ if(content !== undefined) {

@@ -153,3 +153,3 @@ "use strict";

if(this.acknowledged === true) {
return this.createFollowup(content);
return this.createFollowup(content, file);
}

@@ -156,0 +156,0 @@ if(content !== undefined) {

@@ -84,3 +84,3 @@ "use strict";

this._client = client;
this.shard = client.shards.get(client.guildShardMap[this.id] || (Base.getDiscordEpoch(data.id) % client.options.lastShardID) || 0);
this.shard = client.shards.get(client.guildShardMap[this.id] || (Base.getDiscordEpoch(data.id) % client.options.maxShards) || 0);
this.unavailable = !!data.unavailable;

@@ -397,2 +397,3 @@ this.joinedAt = Date.parse(data.joined_at);

* @arg {Array} [options.permissionOverwrites] An array containing permission overwrite objects
* @arg {Number} [options.position] The sorting position of the channel
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (text channels only)

@@ -402,3 +403,3 @@ * @arg {String} [options.reason] The reason to be displayed in audit logs

* @arg {Number} [options.userLimit] The channel user limit (voice channels only)
* @returns {Promise<CategoryChannel | TextChannel | VoiceChannel>}
* @returns {Promise<CategoryChannel | TextChannel | TextVoiceChannel>}
*/

@@ -691,2 +692,3 @@ createChannel(name, type, reason, options) {

* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
* @arg {Boolean} [options.deaf] Server deafen the member

@@ -766,3 +768,3 @@ * @arg {Boolean} [options.mute] Server mute the member

/**
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#update-others-voice-state-caveats)
* Update a user's voice state - See [caveats](https://discord.com/developers/docs/resources/guild#modify-user-voice-state-caveats)
* @arg {Object} options The properties to edit

@@ -950,3 +952,3 @@ * @arg {String} options.channelID The ID of the channel the user is currently in

* Get a guild's channels via the REST API. REST mode is required to use this endpoint.
* @returns {Promise<Array<CategoryChannel> | Array<TextChannel> | Array<VoiceChannel>>}
* @returns {Promise<Array<CategoryChannel> | Array<TextChannel> | Array<TextVoiceChannel>>}
*/

@@ -953,0 +955,0 @@ getRESTChannels() {

@@ -14,3 +14,3 @@ "use strict";

* For example, if a channel was renamed from #general to #potato, this would be `{name: "general"}``
* @prop {(CategoryChannel | TextChannel | VoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | StageChannel)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE), 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) and 83/84/85 (STAGE_INSTANCE_CREATE/UPDATE/DELETE) only
* @prop {(CategoryChannel | TextChannel | TextVoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel | StageChannel)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE), 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) and 83/84/85 (STAGE_INSTANCE_CREATE/UPDATE/DELETE) only
* @prop {Number?} count The number of entities targeted

@@ -26,6 +26,6 @@ * For example, for action type 26 (MEMBER_MOVE), this is the number of members that were moved/disconnected from the voice channel

* @prop {(Role | Object)?} role The role described by the permission overwrite, action types 13-15 (CHANNEL\_OVERWRITE\_CREATE/UPDATE/DELETE) only. If the role is not cached, this could be {id: String, name: String}
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | VoiceChannel | NewsChannel)?} target The object of the action target
* @prop {(CategoryChannel | Guild | Member | Invite | Role | Object | TextChannel | TextVoiceChannel | NewsChannel)?} target The object of the action target
* If the item is not cached, this property will be null
* If the action targets a guild, this could be a Guild object
* If the action targets a guild channel, this could be a CategoryChannel, TextChannel, or VoiceChannel object
* If the action targets a guild channel, this could be a CategoryChannel, TextChannel, or TextVoiceChannel object
* If the action targets a member, this could be a Member object

@@ -32,0 +32,0 @@ * If the action targets a role, this could be a Role object

@@ -10,3 +10,3 @@ "use strict";

/**
* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, and VoiceChannel. See Channel for extra properties.
* Represents a guild channel. You also probably want to look at CategoryChannel, NewsChannel, StoreChannel, TextChannel, and TextVoiceChannel. See Channel for extra properties.
* @extends Channel

@@ -77,2 +77,3 @@ * @prop {Guild} guild The guild that owns the channel

* @arg {Number} [options.autoArchiveDuration] The duration in minutes to automatically archive the thread after recent activity, either 60, 1440, 4320 or 10080 (thread channels only)
* @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only)
* @arg {Number?} [options.defaultAutoArchiveDuration] The default duration of newly created threads in minutes to automatically archive the thread after inactivity (60, 1440, 4320, 10080) (guild text/news channels only)

@@ -82,12 +83,12 @@ * @arg {Boolean} [options.invitable] Whether non-moderators can add other non-moderators to the channel (private thread channels only)

* @arg {String} [options.name] The name of the channel
* @arg {Boolean} [options.nsfw] The nsfw status of the channel
* @arg {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) or the channel ID where the thread originated from (thread channels only)
* @arg {Number} [options.position] The sorting position of the channel
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only)
* @arg {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only)
* @arg {String} [options.topic] The topic of the channel (guild text channels only)
* @arg {Number} [options.bitrate] The bitrate of the channel (guild voice channels only)
* @arg {Number} [options.userLimit] The channel user limit (guild voice channels only)
* @arg {Number} [options.videoQualityMode] The camera video quality mode of the channel (guild voice channels only). `1` is auto, `2` is 720p
* @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (does not affect bots or users with manageMessages/manageChannel permissions) (guild text and thread channels only)
* @arg {String?} [options.rtcRegion] The RTC region ID of the channel (automatic if `null`) (guild voice channels only)
* @arg {Boolean} [options.nsfw] The nsfw status of the channel
* @arg {Number?} [options.parentID] The ID of the parent channel category for this channel (guild text/voice channels only) or the channel ID where the thread originated from (thread channels only)
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<CategoryChannel | GroupChannel | TextChannel | VoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>}
* @returns {Promise<CategoryChannel | GroupChannel | TextChannel | TextVoiceChannel | NewsChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel>}
*/

@@ -94,0 +95,0 @@ edit(options, reason) {

@@ -46,3 +46,3 @@ "use strict";

this._client.emit("warn", new Error(`Unknown interaction type: ${data.type}\n${JSON.stringify(data)}`));
client.emit("warn", new Error(`Unknown interaction type: ${data.type}\n${JSON.stringify(data)}`));
return new UnknownInteraction(data, client);

@@ -49,0 +49,0 @@ }

@@ -8,3 +8,3 @@ "use strict";

* Represents an invite. Some properties are only available when fetching invites from channels, which requires the Manage Channel permission.
* @prop {TextChannel | NewsChannel | VoiceChannel | GroupChannel | StageChannel | Object} channel Info on the invite channel
* @prop {TextChannel | NewsChannel | TextVoiceChannel | GroupChannel | StageChannel | Object} channel Info on the invite channel
* @prop {String} channel.id The ID of the invite's channel

@@ -11,0 +11,0 @@ * @prop {String?} channel.name The name of the invite's channel

@@ -21,2 +21,3 @@ "use strict";

* @prop {String} clientStatus.mobile The member's status on mobile. Either "online", "idle", "dnd", or "offline". Will be "offline" for bots
* @prop {Number?} communicationDisabledUntil Timestamp of timeout expiry. If `null`, the member is not timed out
* @prop {Number} createdAt Timestamp of user creation

@@ -38,3 +39,3 @@ * @prop {String} defaultAvatar The hash for the default avatar of a user if there is no avatar set

* @prop {Permission} permissions The guild-wide permissions of the member
* @prop {Number} premiumSince Timestamp of when the member boosted the guild
* @prop {Number?} premiumSince Timestamp of when the member boosted the guild
* @prop {Array<String>} roles An array of role IDs this member is a part of

@@ -62,3 +63,7 @@ * @prop {String} staticAvatarURL The URL of the user's avatar (always a JPG)

} else if(data.user) {
this.user = new User(data.user, client);
if(!client) {
this.user = new User(data.user);
} else {
this.user = client.users.update(data.user, client);
}
} else {

@@ -87,3 +92,3 @@ this.user = null;

if(data.premium_since !== undefined) {
this.premiumSince = data.premium_since;
this.premiumSince = data.premium_since === null ? null : Date.parse(data.premium_since);
}

@@ -112,2 +117,9 @@ if(data.hasOwnProperty("mute") && this.guild) {

}
if(data.communication_disabled_until !== undefined) {
if(data.communication_disabled_until !== null) {
this.communicationDisabledUntil = Date.parse(data.communication_disabled_until);
} else {
this.communicationDisabledUntil = data.communication_disabled_until;
}
}
}

@@ -210,2 +222,3 @@

* @arg {String?} [options.channelID] The ID of the voice channel to move the member to (must be in voice). Set to `null` to disconnect the member
* @arg {Date?} [options.communicationDisabledUntil] When the user's timeout should expire. Set to `null` to instantly remove timeout
* @arg {Boolean} [options.deaf] Server deafen the user

@@ -253,2 +266,3 @@ * @arg {Boolean} [options.mute] Server mute the user

"activities",
"communicationDisabledUntil",
"joinedAt",

@@ -255,0 +269,0 @@ "nick",

@@ -380,3 +380,3 @@ "use strict";

get jumpLink() {
return `${Endpoints.CLIENT_URL}${Endpoints.MESSAGE_LINK(this.channel.type === 1 ? "@me" : this.channel.guild.id, this.channel.id, this.id)}`;
return `${Endpoints.CLIENT_URL}${Endpoints.MESSAGE_LINK(this.guildID || "@me", this.channel.id, this.id)}`; // Messages outside of guilds (DMs) will never have a guildID property assigned
}

@@ -383,0 +383,0 @@

@@ -48,6 +48,9 @@ "use strict";

* Check if this permission allows a specific permission
* @arg {String} permission The name of the permission. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference)
* @arg {String | BigInt} permission The name of the permission, or bit of permissions. [A full list of permission nodes can be found on the docs reference page](/Eris/docs/reference). Pass a BigInt if you want to check multiple permissions.
* @returns {Boolean} Whether the permission allows the specified permission
*/
has(permission) {
if(typeof permission === "bigint") {
return (this.allow & permission) === permission;
}
return !!(this.allow & Permissions[permission]);

@@ -54,0 +57,0 @@ }

@@ -35,3 +35,3 @@ "use strict";

this.lastMessageID = data.last_message_id || null;
this.ownerID = data.ownerID;
this.ownerID = data.owner_id;
this.update(data);

@@ -38,0 +38,0 @@ }

@@ -162,3 +162,3 @@ "use strict";

if(this.acknowledged === true) {
return this.createFollowup(content);
return this.createFollowup(content, file);
}

@@ -165,0 +165,0 @@ if(content !== undefined) {

@@ -191,3 +191,3 @@ "use strict";

for(const vc of this.voiceConnections.values()) {
vc.timestamp = (vc.timestamp + val) & 0xFFFFFFFF;
vc.timestamp = (vc.timestamp + val) >>> 0;
}

@@ -194,0 +194,0 @@ }

@@ -644,3 +644,3 @@ "use strict";

sendAudioFrame(frame, frameSize = this.frameSize) {
this.timestamp = (this.timestamp + frameSize) & 0xFFFFFFFF;
this.timestamp = (this.timestamp + frameSize) >>> 0;
this.sequence = (this.sequence + 1) & 0xFFFF;

@@ -794,3 +794,3 @@

this.current.pausedTime += 4 * this.current.options.frameDuration;
this.timestamp = (this.timestamp + 3 * this.current.options.frameSize) & 0xFFFFFFFF;
this.timestamp = (this.timestamp + 3 * this.current.options.frameSize) >>> 0;
this.current.timeout = setTimeout(this._send, 4 * this.current.options.frameDuration);

@@ -797,0 +797,0 @@ return;

{
"name": "eris",
"version": "0.16.1",
"version": "0.17.0",
"description": "A NodeJS Discord library",

@@ -5,0 +5,0 @@ "main": "./index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc