mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-15 02:53:31 +01:00
refactor: PresenceUpdate and demuxProbe (#7248)
This commit is contained in:
@@ -6,10 +6,10 @@ const { Events } = require('../../util/Constants');
|
|||||||
class PresenceUpdateAction extends Action {
|
class PresenceUpdateAction extends Action {
|
||||||
handle(data) {
|
handle(data) {
|
||||||
let user = this.client.users.cache.get(data.user.id);
|
let user = this.client.users.cache.get(data.user.id);
|
||||||
if (!user && data.user?.username) user = this.client.users._add(data.user);
|
if (!user && data.user.username) user = this.client.users._add(data.user);
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|
||||||
if (data.user?.username) {
|
if (data.user.username) {
|
||||||
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
if (!user._equals(data.user)) this.client.actions.UserUpdate.handle(data.user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ export function demuxProbe(
|
|||||||
): Promise<ProbeInfo> {
|
): Promise<ProbeInfo> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// Preconditions
|
// Preconditions
|
||||||
if (stream.readableObjectMode) reject(new Error('Cannot probe a readable stream in object mode'));
|
if (stream.readableObjectMode) return reject(new Error('Cannot probe a readable stream in object mode'));
|
||||||
if (stream.readableEnded) reject(new Error('Cannot probe a stream that has ended'));
|
if (stream.readableEnded) return reject(new Error('Cannot probe a stream that has ended'));
|
||||||
|
|
||||||
let readBuffer = Buffer.alloc(0);
|
let readBuffer = Buffer.alloc(0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user