Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-slim

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-slim - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

2

dist/client.d.ts

@@ -23,2 +23,4 @@ /// <reference types="node" />

private _send;
private _dispatchHandlers;
private _intentHandlers;
private _onMessage;

@@ -25,0 +27,0 @@ private _identify;

77

dist/client.js

@@ -50,44 +50,41 @@ import WebSocket from 'ws';

this._send = (op, d) => this._ws && this._ws.send(JSON.stringify({ op, d }));
this._dispatchHandlers = {
["READY"]: (d) => {
const { user, session_id } = d;
this._user = user;
this._sessionId = session_id;
this.emit(ClientEvents.CONNECT);
},
["RESUMED"]: () => this.emit(ClientEvents.CONNECT),
};
this._intentHandlers = {
[0]: (intent) => {
const { t, s, d } = intent;
if (s && (s > this._lastSequence))
this._lastSequence = s;
this._dispatchHandlers[t]?.(d);
this.emit(ClientEvents.INTENT, intent);
this._eventHandler.emit(t, d);
},
[10]: (intent) => {
this._identify();
this._lastHeartbeatAck = true;
this._setHeartbeatTimer(intent.d.heartbeat_interval);
this._sendHeartbeat();
},
[11]: () => this._lastHeartbeatAck = true,
[1]: () => this._sendHeartbeat(),
[9]: (intent) => {
const { d } = intent;
this.emit(ClientEvents.WARN, `Invalid session. Resumable: ${d}`);
this._wsConnect(d);
},
[7]: () => {
this.emit(ClientEvents.WARN, 'Server forced reconnect.');
this._wsConnect(true);
},
};
this._onMessage = (data) => {
const intent = SafeJsonParse(String(data));
if (!intent)
return;
switch (intent.op) {
case 0:
if (intent.s && (intent.s > this._lastSequence))
this._lastSequence = intent.s;
switch (intent.t) {
case "READY":
this._user = intent.d.user;
this._sessionId = intent.d.session_id;
this.emit(ClientEvents.CONNECT);
break;
case "RESUMED":
this.emit(ClientEvents.CONNECT);
break;
}
this.emit(ClientEvents.INTENT, intent);
this._eventHandler.emit(intent.t, intent.d);
break;
case 10:
this._identify();
this._lastHeartbeatAck = true;
this._setHeartbeatTimer(intent.d.heartbeat_interval);
this._sendHeartbeat();
break;
case 11:
this._lastHeartbeatAck = true;
break;
case 1:
this._sendHeartbeat();
break;
case 9:
this.emit(ClientEvents.WARN, `Invalid session. Resumable: ${intent.d}`);
this._wsConnect(intent.d);
break;
case 7:
this.emit(ClientEvents.WARN, 'Server forced reconnect.');
this._wsConnect(true);
break;
}
intent && this._intentHandlers[intent.op]?.(intent);
};

@@ -94,0 +91,0 @@ this._identify = () => this._sessionId ?

@@ -61,2 +61,6 @@ import { Permissions as Flags, TimestampStyles } from './helpers.js';

}, size?: number | undefined, ext?: "png" | "jpg" | "webp" | "gif" | undefined) => string;
UserBanner: (user: User | {
id: string;
banner: string;
}, size?: number | undefined, ext?: "png" | "jpg" | "webp" | "gif" | undefined) => string | null;
ApplicationIcon: (application: Application | {

@@ -63,0 +67,0 @@ id: string;

@@ -50,2 +50,3 @@ import { Permissions as Flags, CDN, HOST } from './helpers.js';

`${CDN}/embed/avatars/${Number(user.discriminator) % 5}.png`,
UserBanner: (user, size, ext) => user.banner ? `${CDN}/banners/${user.id}/${user.banner}${SizeExtOpt(size, ext)}` : null,
ApplicationIcon: (application, size, ext) => application.icon ? `${CDN}/app-icons/${application.id}/${application.icon}${SizeExtOpt(size, ext)}` : null,

@@ -52,0 +53,0 @@ ApplicationAsset: (application, asset_id, size, ext) => `${CDN}/app-assets/${EID(application)}/${asset_id}${SizeExtOpt(size, ext)}`,

@@ -515,2 +515,4 @@ import type * as helpers from './helpers';

mfa_enabled?: boolean;
banner?: string | null;
accent_color?: number | null;
locale?: string;

@@ -517,0 +519,0 @@ verified?: boolean;

@@ -18,2 +18,3 @@ /// <reference types="node" />

private _send;
private _intentHandlers;
private _onMessage;

@@ -20,0 +21,0 @@ private _sendHeartbeat;

@@ -34,36 +34,31 @@ import WebSocket from 'ws';

this._send = (op, d) => this._ws && this._ws.send(JSON.stringify({ op, d }));
this._intentHandlers = {
[8]: (d) => {
this._send(this._resume ? 7 : 0, this._options);
this._resume = true;
this._lastHeartbeatAck = true;
this._setHeartbeatTimer(d.heartbeat_interval);
this._sendHeartbeat();
},
[2]: (d) => {
const { ssrc, ip, port } = d;
this._broadcast = { ssrc, ip, port };
this._send(1, {
protocol: 'udp',
data: {
address: ip,
port,
mode: this._encryption,
},
});
},
[4]: (d) => {
const { secret_key } = d;
this.emit(VoiceEvents.CONNECT, { ...this._broadcast, secret_key });
},
[6]: () => this._lastHeartbeatAck = true,
};
this._onMessage = (data) => {
const intent = SafeJsonParse(String(data));
if (!intent)
return;
switch (intent.op) {
case 8:
this._send(this._resume ? 7 : 0, this._options);
this._resume = true;
this._lastHeartbeatAck = true;
this._setHeartbeatTimer(intent.d.heartbeat_interval);
this._sendHeartbeat();
break;
case 2:
this._broadcast = {
ip: intent.d.ip,
ssrc: intent.d.ssrc,
port: intent.d.port,
};
this._send(1, {
protocol: 'udp',
data: {
address: intent.d.ip,
port: intent.d.port,
mode: this._encryption,
},
});
break;
case 4:
this.emit(VoiceEvents.CONNECT, { ...this._broadcast, secret_key: intent.d.secret_key });
break;
case 6:
this._lastHeartbeatAck = true;
break;
}
intent && this._intentHandlers[intent.op]?.(intent.d);
};

@@ -70,0 +65,0 @@ this._sendHeartbeat = () => {

{
"name": "discord-slim",
"version": "2.2.2",
"version": "2.2.3",
"description": "Lightweight Discord API library for Node.js.",

@@ -29,3 +29,3 @@ "author": "Hanabishi",

"dependencies": {
"ws": "8.1.*"
"ws": "8.2.*"
},

@@ -32,0 +32,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc