mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-23 03:50:09 +00:00
Compare commits
9 Commits
@discordjs
...
12.5.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51551f544b | ||
|
|
5291fe11a3 | ||
|
|
6e11596cb1 | ||
|
|
7efc295415 | ||
|
|
8e8d9b490a | ||
|
|
8a7abc9f06 | ||
|
|
a6b922f8ae | ||
|
|
5328648f45 | ||
|
|
f8b0c01c26 |
2698
package-lock.json
generated
2698
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",
|
||||
"version": "12.5.0",
|
||||
"version": "12.5.3",
|
||||
"description": "A powerful library for interacting with the Discord API",
|
||||
"main": "./src/index",
|
||||
"types": "./typings/index.d.ts",
|
||||
@@ -51,31 +51,31 @@
|
||||
"@discordjs/form-data": "^3.0.1",
|
||||
"abort-controller": "^3.0.0",
|
||||
"node-fetch": "^2.6.1",
|
||||
"prism-media": "^1.2.2",
|
||||
"prism-media": "^1.2.9",
|
||||
"setimmediate": "^1.0.5",
|
||||
"tweetnacl": "^1.0.3",
|
||||
"ws": "^7.3.1"
|
||||
"ws": "^7.4.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^11.0.0",
|
||||
"@commitlint/config-angular": "^11.0.0",
|
||||
"@commitlint/cli": "^12.0.1",
|
||||
"@commitlint/config-angular": "^12.0.1",
|
||||
"@types/node": "^12.12.6",
|
||||
"@types/ws": "^7.2.7",
|
||||
"cross-env": "^7.0.2",
|
||||
"@types/ws": "^7.4.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"discord.js-docgen": "git+https://github.com/discordjs/docgen.git",
|
||||
"dtslint": "^4.0.4",
|
||||
"eslint": "^7.11.0",
|
||||
"dtslint": "^4.0.8",
|
||||
"eslint": "^7.23.0",
|
||||
"eslint-config-prettier": "^6.13.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
"eslint-plugin-prettier": "^3.1.4",
|
||||
"eslint-plugin-prettier": "^3.3.1",
|
||||
"husky": "^4.3.0",
|
||||
"jest": "^26.6.0",
|
||||
"jest": "^26.6.3",
|
||||
"json-filter-loader": "^1.0.0",
|
||||
"lint-staged": "^10.4.2",
|
||||
"prettier": "^2.1.2",
|
||||
"lint-staged": "^10.5.4",
|
||||
"prettier": "^2.2.1",
|
||||
"terser-webpack-plugin": "^4.2.3",
|
||||
"tslint": "^6.1.3",
|
||||
"typescript": "^4.0.3",
|
||||
"typescript": "^4.2.3",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^3.3.12"
|
||||
},
|
||||
|
||||
@@ -9,7 +9,7 @@ class InviteDeleteAction extends Action {
|
||||
const client = this.client;
|
||||
const channel = client.channels.cache.get(data.channel_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 invite = new Invite(client, inviteData);
|
||||
|
||||
@@ -56,8 +56,14 @@ class ClientVoiceManager {
|
||||
this.connections.delete(guild_id);
|
||||
return;
|
||||
}
|
||||
connection.channel = this.client.channels.cache.get(channel_id);
|
||||
connection.setSessionID(session_id);
|
||||
const channel = this.client.channels.cache.get(channel_id);
|
||||
if (channel) {
|
||||
connection.channel = channel;
|
||||
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 }) {
|
||||
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);
|
||||
break;
|
||||
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;
|
||||
case VoiceOPCodes.CLIENT_DISCONNECT:
|
||||
const streamInfo = this.connection.receiver && this.connection.receiver.packets.streams.get(packet.d.user_id);
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const EventEmitter = require('events');
|
||||
const Speaking = require('../../../util/Speaking');
|
||||
const secretbox = require('../util/Secretbox');
|
||||
const { SILENCE_FRAME } = require('../util/Silence');
|
||||
|
||||
// The delay between packets when a user is considered to have stopped speaking
|
||||
// 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);
|
||||
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);
|
||||
if (typeof speakingTimeout === 'undefined') {
|
||||
// Ensure at least the speaking bit is set.
|
||||
// As the object is by reference, it's only needed once per client re-connect.
|
||||
if (userStat.speaking === 0) {
|
||||
userStat.speaking = 1;
|
||||
userStat.speaking = Speaking.FLAGS.SPEAKING;
|
||||
}
|
||||
this.connection.onSpeaking({ user_id: userStat.userID, ssrc: ssrc, speaking: userStat.speaking });
|
||||
speakingTimeout = this.receiver.connection.client.setTimeout(() => {
|
||||
@@ -106,15 +126,17 @@ class PacketHandler extends EventEmitter {
|
||||
speakingTimeout.refresh();
|
||||
}
|
||||
|
||||
let stream = this.streams.get(userStat.userID);
|
||||
if (!stream) return;
|
||||
stream = stream.stream;
|
||||
const opusPacket = this.parseBuffer(buffer);
|
||||
if (opusPacket instanceof Error) {
|
||||
this.emit('error', opusPacket);
|
||||
return;
|
||||
if (streamInfo) {
|
||||
const { stream } = streamInfo;
|
||||
if (!opusPacket) {
|
||||
opusPacket = this.parseBuffer(buffer);
|
||||
if (opusPacket instanceof Error) {
|
||||
this.emit('error', opusPacket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
stream.push(opusPacket);
|
||||
}
|
||||
stream.push(opusPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,4 +10,6 @@ class Silence extends Readable {
|
||||
}
|
||||
}
|
||||
|
||||
Silence.SILENCE_FRAME = SILENCE_FRAME;
|
||||
|
||||
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 {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
|
||||
|
||||
@@ -198,8 +198,9 @@ class GuildTemplate extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get guild() {
|
||||
return this.client.guilds.get(this.guildID) || null;
|
||||
return this.client.guilds.cache.get(this.guildID) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The URL of this template
|
||||
* @type {string}
|
||||
|
||||
@@ -28,12 +28,6 @@ class MessageReaction {
|
||||
*/
|
||||
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
|
||||
* @type {ReactionUserManager}
|
||||
@@ -54,6 +48,12 @@ class MessageReaction {
|
||||
*/
|
||||
this.count = data.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the client has given this reaction
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.me = data.me;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user