mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-28 06:20:10 +00:00
Compare commits
9 Commits
@discordjs
...
v12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51551f544b | ||
|
|
5291fe11a3 | ||
|
|
6e11596cb1 | ||
|
|
7efc295415 | ||
|
|
8e8d9b490a | ||
|
|
8a7abc9f06 | ||
|
|
a6b922f8ae | ||
|
|
5328648f45 | ||
|
|
f8b0c01c26 |
2684
package-lock.json
generated
2684
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "discord.js",
|
"name": "discord.js",
|
||||||
"version": "12.5.0",
|
"version": "12.5.3",
|
||||||
"description": "A powerful library for interacting with the Discord API",
|
"description": "A powerful library for interacting with the Discord API",
|
||||||
"main": "./src/index",
|
"main": "./src/index",
|
||||||
"types": "./typings/index.d.ts",
|
"types": "./typings/index.d.ts",
|
||||||
@@ -51,31 +51,31 @@
|
|||||||
"@discordjs/form-data": "^3.0.1",
|
"@discordjs/form-data": "^3.0.1",
|
||||||
"abort-controller": "^3.0.0",
|
"abort-controller": "^3.0.0",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"prism-media": "^1.2.2",
|
"prism-media": "^1.2.9",
|
||||||
"setimmediate": "^1.0.5",
|
"setimmediate": "^1.0.5",
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"ws": "^7.3.1"
|
"ws": "^7.4.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^11.0.0",
|
"@commitlint/cli": "^12.0.1",
|
||||||
"@commitlint/config-angular": "^11.0.0",
|
"@commitlint/config-angular": "^12.0.1",
|
||||||
"@types/node": "^12.12.6",
|
"@types/node": "^12.12.6",
|
||||||
"@types/ws": "^7.2.7",
|
"@types/ws": "^7.4.0",
|
||||||
"cross-env": "^7.0.2",
|
"cross-env": "^7.0.3",
|
||||||
"discord.js-docgen": "git+https://github.com/discordjs/docgen.git",
|
"discord.js-docgen": "git+https://github.com/discordjs/docgen.git",
|
||||||
"dtslint": "^4.0.4",
|
"dtslint": "^4.0.8",
|
||||||
"eslint": "^7.11.0",
|
"eslint": "^7.23.0",
|
||||||
"eslint-config-prettier": "^6.13.0",
|
"eslint-config-prettier": "^6.13.0",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-prettier": "^3.1.4",
|
"eslint-plugin-prettier": "^3.3.1",
|
||||||
"husky": "^4.3.0",
|
"husky": "^4.3.0",
|
||||||
"jest": "^26.6.0",
|
"jest": "^26.6.3",
|
||||||
"json-filter-loader": "^1.0.0",
|
"json-filter-loader": "^1.0.0",
|
||||||
"lint-staged": "^10.4.2",
|
"lint-staged": "^10.5.4",
|
||||||
"prettier": "^2.1.2",
|
"prettier": "^2.2.1",
|
||||||
"terser-webpack-plugin": "^4.2.3",
|
"terser-webpack-plugin": "^4.2.3",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"typescript": "^4.0.3",
|
"typescript": "^4.2.3",
|
||||||
"webpack": "^4.44.2",
|
"webpack": "^4.44.2",
|
||||||
"webpack-cli": "^3.3.12"
|
"webpack-cli": "^3.3.12"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class InviteDeleteAction extends Action {
|
|||||||
const client = this.client;
|
const client = this.client;
|
||||||
const channel = client.channels.cache.get(data.channel_id);
|
const channel = client.channels.cache.get(data.channel_id);
|
||||||
const guild = client.guilds.cache.get(data.guild_id);
|
const guild = client.guilds.cache.get(data.guild_id);
|
||||||
if (!channel && !guild) return false;
|
if (!channel) return false;
|
||||||
|
|
||||||
const inviteData = Object.assign(data, { channel, guild });
|
const inviteData = Object.assign(data, { channel, guild });
|
||||||
const invite = new Invite(client, inviteData);
|
const invite = new Invite(client, inviteData);
|
||||||
|
|||||||
@@ -56,8 +56,14 @@ class ClientVoiceManager {
|
|||||||
this.connections.delete(guild_id);
|
this.connections.delete(guild_id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connection.channel = this.client.channels.cache.get(channel_id);
|
const channel = this.client.channels.cache.get(channel_id);
|
||||||
|
if (channel) {
|
||||||
|
connection.channel = channel;
|
||||||
connection.setSessionID(session_id);
|
connection.setSessionID(session_id);
|
||||||
|
} else {
|
||||||
|
this.client.emit('debug', `[VOICE] disconnecting from guild ${guild_id} as channel ${channel_id} is uncached`);
|
||||||
|
connection.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -473,7 +473,11 @@ class VoiceConnection extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onStartSpeaking({ user_id, ssrc, speaking }) {
|
onStartSpeaking({ user_id, ssrc, speaking }) {
|
||||||
this.ssrcMap.set(+ssrc, { userID: user_id, speaking: speaking });
|
this.ssrcMap.set(+ssrc, {
|
||||||
|
...(this.ssrcMap.get(+ssrc) || {}),
|
||||||
|
userID: user_id,
|
||||||
|
speaking: speaking,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -189,7 +189,11 @@ class VoiceWebSocket extends EventEmitter {
|
|||||||
this.emit('sessionDescription', packet.d);
|
this.emit('sessionDescription', packet.d);
|
||||||
break;
|
break;
|
||||||
case VoiceOPCodes.CLIENT_CONNECT:
|
case VoiceOPCodes.CLIENT_CONNECT:
|
||||||
this.connection.ssrcMap.set(+packet.d.audio_ssrc, { userID: packet.d.user_id, speaking: 0 });
|
this.connection.ssrcMap.set(+packet.d.audio_ssrc, {
|
||||||
|
userID: packet.d.user_id,
|
||||||
|
speaking: 0,
|
||||||
|
hasVideo: Boolean(packet.d.video_ssrc),
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
case VoiceOPCodes.CLIENT_DISCONNECT:
|
case VoiceOPCodes.CLIENT_DISCONNECT:
|
||||||
const streamInfo = this.connection.receiver && this.connection.receiver.packets.streams.get(packet.d.user_id);
|
const streamInfo = this.connection.receiver && this.connection.receiver.packets.streams.get(packet.d.user_id);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const EventEmitter = require('events');
|
const EventEmitter = require('events');
|
||||||
|
const Speaking = require('../../../util/Speaking');
|
||||||
const secretbox = require('../util/Secretbox');
|
const secretbox = require('../util/Secretbox');
|
||||||
|
const { SILENCE_FRAME } = require('../util/Silence');
|
||||||
|
|
||||||
// The delay between packets when a user is considered to have stopped speaking
|
// The delay between packets when a user is considered to have stopped speaking
|
||||||
// https://github.com/discordjs/discord.js/issues/3524#issuecomment-540373200
|
// https://github.com/discordjs/discord.js/issues/3524#issuecomment-540373200
|
||||||
@@ -84,12 +86,30 @@ class PacketHandler extends EventEmitter {
|
|||||||
const userStat = this.connection.ssrcMap.get(ssrc);
|
const userStat = this.connection.ssrcMap.get(ssrc);
|
||||||
if (!userStat) return;
|
if (!userStat) return;
|
||||||
|
|
||||||
|
let opusPacket;
|
||||||
|
const streamInfo = this.streams.get(userStat.userID);
|
||||||
|
// If the user is in video, we need to check if the packet is just silence
|
||||||
|
if (userStat.hasVideo) {
|
||||||
|
opusPacket = this.parseBuffer(buffer);
|
||||||
|
if (opusPacket instanceof Error) {
|
||||||
|
// Only emit an error if we were actively receiving packets from this user
|
||||||
|
if (streamInfo) {
|
||||||
|
this.emit('error', opusPacket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (SILENCE_FRAME.equals(opusPacket)) {
|
||||||
|
// If this is a silence frame, pretend we never received it
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let speakingTimeout = this.speakingTimeouts.get(ssrc);
|
let speakingTimeout = this.speakingTimeouts.get(ssrc);
|
||||||
if (typeof speakingTimeout === 'undefined') {
|
if (typeof speakingTimeout === 'undefined') {
|
||||||
// Ensure at least the speaking bit is set.
|
// Ensure at least the speaking bit is set.
|
||||||
// As the object is by reference, it's only needed once per client re-connect.
|
// As the object is by reference, it's only needed once per client re-connect.
|
||||||
if (userStat.speaking === 0) {
|
if (userStat.speaking === 0) {
|
||||||
userStat.speaking = 1;
|
userStat.speaking = Speaking.FLAGS.SPEAKING;
|
||||||
}
|
}
|
||||||
this.connection.onSpeaking({ user_id: userStat.userID, ssrc: ssrc, speaking: userStat.speaking });
|
this.connection.onSpeaking({ user_id: userStat.userID, ssrc: ssrc, speaking: userStat.speaking });
|
||||||
speakingTimeout = this.receiver.connection.client.setTimeout(() => {
|
speakingTimeout = this.receiver.connection.client.setTimeout(() => {
|
||||||
@@ -106,16 +126,18 @@ class PacketHandler extends EventEmitter {
|
|||||||
speakingTimeout.refresh();
|
speakingTimeout.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
let stream = this.streams.get(userStat.userID);
|
if (streamInfo) {
|
||||||
if (!stream) return;
|
const { stream } = streamInfo;
|
||||||
stream = stream.stream;
|
if (!opusPacket) {
|
||||||
const opusPacket = this.parseBuffer(buffer);
|
opusPacket = this.parseBuffer(buffer);
|
||||||
if (opusPacket instanceof Error) {
|
if (opusPacket instanceof Error) {
|
||||||
this.emit('error', opusPacket);
|
this.emit('error', opusPacket);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
stream.push(opusPacket);
|
stream.push(opusPacket);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = PacketHandler;
|
module.exports = PacketHandler;
|
||||||
|
|||||||
@@ -10,4 +10,6 @@ class Silence extends Readable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Silence.SILENCE_FRAME = SILENCE_FRAME;
|
||||||
|
|
||||||
module.exports = Silence;
|
module.exports = Silence;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class ReactionUserManager extends BaseManager {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all the users that gave this reaction. Resolves with a collection of users, mapped by their IDs.
|
* Fetches the users that gave this reaction. Resolves with a collection of users, mapped by their IDs.
|
||||||
* @param {Object} [options] Options for fetching the users
|
* @param {Object} [options] Options for fetching the users
|
||||||
* @param {number} [options.limit=100] The maximum amount of users to fetch, defaults to 100
|
* @param {number} [options.limit=100] The maximum amount of users to fetch, defaults to 100
|
||||||
* @param {Snowflake} [options.before] Limit fetching users to those with an id lower than the supplied id
|
* @param {Snowflake} [options.before] Limit fetching users to those with an id lower than the supplied id
|
||||||
|
|||||||
@@ -198,8 +198,9 @@ class GuildTemplate extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get guild() {
|
get guild() {
|
||||||
return this.client.guilds.get(this.guildID) || null;
|
return this.client.guilds.cache.get(this.guildID) || null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL of this template
|
* The URL of this template
|
||||||
* @type {string}
|
* @type {string}
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ class MessageReaction {
|
|||||||
*/
|
*/
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the client has given this reaction
|
|
||||||
* @type {boolean}
|
|
||||||
*/
|
|
||||||
this.me = data.me;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A manager of the users that have given this reaction
|
* A manager of the users that have given this reaction
|
||||||
* @type {ReactionUserManager}
|
* @type {ReactionUserManager}
|
||||||
@@ -54,6 +48,12 @@ class MessageReaction {
|
|||||||
*/
|
*/
|
||||||
this.count = data.count;
|
this.count = data.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the client has given this reaction
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.me = data.me;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user