@hieuxyz/rpc 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -9
- package/dist/hieuxyz/Client.d.ts +0 -100
- package/dist/hieuxyz/Client.js +0 -256
- package/dist/hieuxyz/gateway/DiscordWebSocket.d.ts +0 -69
- package/dist/hieuxyz/gateway/DiscordWebSocket.js +0 -328
- package/dist/hieuxyz/gateway/entities/OpCode.d.ts +0 -13
- package/dist/hieuxyz/gateway/entities/OpCode.js +0 -17
- package/dist/hieuxyz/gateway/entities/identify.d.ts +0 -13
- package/dist/hieuxyz/gateway/entities/identify.js +0 -17
- package/dist/hieuxyz/gateway/entities/types.d.ts +0 -151
- package/dist/hieuxyz/gateway/entities/types.js +0 -30
- package/dist/hieuxyz/rpc/HieuxyzRPC.d.ts +0 -237
- package/dist/hieuxyz/rpc/HieuxyzRPC.js +0 -546
- package/dist/hieuxyz/rpc/ImageService.d.ts +0 -42
- package/dist/hieuxyz/rpc/ImageService.js +0 -142
- package/dist/hieuxyz/rpc/RpcImage.d.ts +0 -69
- package/dist/hieuxyz/rpc/RpcImage.js +0 -136
- package/dist/hieuxyz/utils/logger.d.ts +0 -5
- package/dist/hieuxyz/utils/logger.js +0 -8
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -35
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.DiscordWebSocket = void 0;
|
|
40
|
-
const ws_1 = __importDefault(require("ws"));
|
|
41
|
-
const zlib = __importStar(require("zlib"));
|
|
42
|
-
const logger_1 = require("../utils/logger");
|
|
43
|
-
const identify_1 = require("./entities/identify");
|
|
44
|
-
const OpCode_1 = require("./entities/OpCode");
|
|
45
|
-
/**
|
|
46
|
-
* Manage WebSocket connections to Discord Gateway.
|
|
47
|
-
* Handles low-level operations like heartbeating, identifying, and resuming.
|
|
48
|
-
*/
|
|
49
|
-
class DiscordWebSocket {
|
|
50
|
-
token;
|
|
51
|
-
ws = null;
|
|
52
|
-
sequence = null;
|
|
53
|
-
heartbeatInterval = null;
|
|
54
|
-
heartbeatIntervalValue = 0;
|
|
55
|
-
sessionId = null;
|
|
56
|
-
resumeGatewayUrl = null;
|
|
57
|
-
options;
|
|
58
|
-
isReconnecting = false;
|
|
59
|
-
permanentClose = false;
|
|
60
|
-
connectTimeout = null;
|
|
61
|
-
resolveReady = () => { };
|
|
62
|
-
lastHeartbeatAck = true;
|
|
63
|
-
/**
|
|
64
|
-
* Current logged in user info.
|
|
65
|
-
*/
|
|
66
|
-
user = null;
|
|
67
|
-
/**
|
|
68
|
-
* A promise will be resolved when the Gateway connection is ready.
|
|
69
|
-
* and received the READY event.
|
|
70
|
-
*/
|
|
71
|
-
readyPromise;
|
|
72
|
-
/**
|
|
73
|
-
* Create a DiscordWebSocket instance.
|
|
74
|
-
* @param {string} token - Discord user token for authentication.
|
|
75
|
-
* @param {DiscordWebSocketOptions} options - Configuration options for the WebSocket client.
|
|
76
|
-
* @throws {Error} If the token is invalid.
|
|
77
|
-
*/
|
|
78
|
-
constructor(token, options) {
|
|
79
|
-
if (!this.isTokenValid(token)) {
|
|
80
|
-
throw new Error('Invalid token provided.');
|
|
81
|
-
}
|
|
82
|
-
this.token = token;
|
|
83
|
-
this.options = {
|
|
84
|
-
alwaysReconnect: options.alwaysReconnect ?? false,
|
|
85
|
-
properties: options.properties,
|
|
86
|
-
connectionTimeout: options.connectionTimeout ?? 30000,
|
|
87
|
-
};
|
|
88
|
-
this.readyPromise = new Promise((resolve) => (this.resolveReady = resolve));
|
|
89
|
-
}
|
|
90
|
-
resetReadyPromise() {
|
|
91
|
-
this.readyPromise = new Promise((resolve) => (this.resolveReady = resolve));
|
|
92
|
-
}
|
|
93
|
-
isTokenValid(token) {
|
|
94
|
-
return (/^[a-zA-Z0-9_-]{24}\.[a-zA-Z0-9_-]{6}\.[a-zA-Z0-9_-]{38}$/.test(token) ||
|
|
95
|
-
/^mfa\.[a-zA-Z0-9_-]{84}$/.test(token));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Initiate connection to Discord Gateway.
|
|
99
|
-
* If there was a previous session, it will try to resume.
|
|
100
|
-
*/
|
|
101
|
-
connect() {
|
|
102
|
-
if (this.isReconnecting) {
|
|
103
|
-
logger_1.logger.info('Connection attempt aborted: reconnection already in progress.');
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
this.permanentClose = false;
|
|
107
|
-
this.isReconnecting = true;
|
|
108
|
-
this.resetReadyPromise();
|
|
109
|
-
const url = this.resumeGatewayUrl || 'wss://gateway.discord.gg/?v=10&encoding=json';
|
|
110
|
-
logger_1.logger.info(`Attempting to connect to ${url}...`);
|
|
111
|
-
this.ws = new ws_1.default(url);
|
|
112
|
-
this.connectTimeout = setTimeout(() => {
|
|
113
|
-
logger_1.logger.error('Connection timed out. Terminating connection attempt.');
|
|
114
|
-
if (this.ws) {
|
|
115
|
-
this.ws.terminate();
|
|
116
|
-
}
|
|
117
|
-
}, this.options.connectionTimeout);
|
|
118
|
-
this.ws.on('open', () => {
|
|
119
|
-
logger_1.logger.info(`Successfully connected to Discord Gateway at ${url}.`);
|
|
120
|
-
this.isReconnecting = false;
|
|
121
|
-
if (this.connectTimeout) {
|
|
122
|
-
clearTimeout(this.connectTimeout);
|
|
123
|
-
this.connectTimeout = null;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
this.ws.on('message', this.onMessage.bind(this));
|
|
127
|
-
this.ws.on('close', this.handleClose.bind(this));
|
|
128
|
-
this.ws.on('error', (err) => {
|
|
129
|
-
if (err.message !== 'WebSocket was closed before the connection was established') {
|
|
130
|
-
logger_1.logger.error(`WebSocket Error: ${err.message}`);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
handleClose(code, reason) {
|
|
135
|
-
logger_1.logger.warn(`Connection closed: ${code} - ${reason.toString('utf-8')}`);
|
|
136
|
-
this.cleanupHeartbeat();
|
|
137
|
-
if (this.connectTimeout) {
|
|
138
|
-
clearTimeout(this.connectTimeout);
|
|
139
|
-
this.connectTimeout = null;
|
|
140
|
-
}
|
|
141
|
-
this.isReconnecting = false;
|
|
142
|
-
if (code === 4004 || code === 4999) {
|
|
143
|
-
this.sessionId = null;
|
|
144
|
-
this.sequence = null;
|
|
145
|
-
this.resumeGatewayUrl = null;
|
|
146
|
-
}
|
|
147
|
-
if (this.permanentClose) {
|
|
148
|
-
logger_1.logger.info('Connection permanently closed by client. Not reconnecting.');
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (this.shouldReconnect(code)) {
|
|
152
|
-
logger_1.logger.info('Attempting to reconnect in 5 seconds...');
|
|
153
|
-
setTimeout(() => this.connect(), 5000);
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
logger_1.logger.info('Not attempting to reconnect based on close code and client options.');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
onMessage(data, isBinary) {
|
|
160
|
-
let decompressedData;
|
|
161
|
-
if (isBinary) {
|
|
162
|
-
decompressedData = zlib.inflateSync(data).toString('utf-8');
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
decompressedData = data.toString('utf-8');
|
|
166
|
-
}
|
|
167
|
-
const payload = JSON.parse(decompressedData);
|
|
168
|
-
if (payload.s) {
|
|
169
|
-
this.sequence = payload.s;
|
|
170
|
-
}
|
|
171
|
-
switch (payload.op) {
|
|
172
|
-
case OpCode_1.OpCode.HELLO:
|
|
173
|
-
if (this.connectTimeout) {
|
|
174
|
-
clearTimeout(this.connectTimeout);
|
|
175
|
-
this.connectTimeout = null;
|
|
176
|
-
}
|
|
177
|
-
this.heartbeatIntervalValue = payload.d.heartbeat_interval;
|
|
178
|
-
logger_1.logger.info(`Received HELLO. Setting heartbeat interval to ${this.heartbeatIntervalValue}ms.`);
|
|
179
|
-
this.startHeartbeating();
|
|
180
|
-
if (this.sessionId && this.sequence) {
|
|
181
|
-
this.resume();
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
this.identify();
|
|
185
|
-
}
|
|
186
|
-
break;
|
|
187
|
-
case OpCode_1.OpCode.DISPATCH:
|
|
188
|
-
if (payload.t === 'READY') {
|
|
189
|
-
this.sessionId = payload.d.session_id;
|
|
190
|
-
this.resumeGatewayUrl = payload.d.resume_gateway_url + '/?v=10&encoding=json';
|
|
191
|
-
this.user = payload.d.user;
|
|
192
|
-
logger_1.logger.info(`Session READY. Session ID: ${this.sessionId}. Resume URL set.`);
|
|
193
|
-
this.resolveReady(this.user);
|
|
194
|
-
}
|
|
195
|
-
else if (payload.t === 'RESUMED') {
|
|
196
|
-
logger_1.logger.info('The session has been successfully resumed.');
|
|
197
|
-
if (this.user) {
|
|
198
|
-
this.resolveReady(this.user);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
break;
|
|
202
|
-
case OpCode_1.OpCode.HEARTBEAT_ACK:
|
|
203
|
-
logger_1.logger.info('Heartbeat acknowledged.');
|
|
204
|
-
this.lastHeartbeatAck = true;
|
|
205
|
-
break;
|
|
206
|
-
case OpCode_1.OpCode.INVALID_SESSION:
|
|
207
|
-
logger_1.logger.warn(`Received INVALID_SESSION. Resumable: ${payload.d}`);
|
|
208
|
-
if (payload.d) {
|
|
209
|
-
this.ws?.close(4000, 'Invalid session, attempting to resume.');
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
this.sessionId = null;
|
|
213
|
-
this.sequence = null;
|
|
214
|
-
this.ws?.close(4004, 'Invalid session, starting a new session.');
|
|
215
|
-
}
|
|
216
|
-
break;
|
|
217
|
-
case OpCode_1.OpCode.RECONNECT:
|
|
218
|
-
logger_1.logger.info('Gateway requested RECONNECT. Closing to reconnect and resume.');
|
|
219
|
-
this.ws?.close(4000, 'Gateway requested reconnect.');
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
break;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
startHeartbeating() {
|
|
226
|
-
this.cleanupHeartbeat();
|
|
227
|
-
this.lastHeartbeatAck = true;
|
|
228
|
-
setTimeout(() => {
|
|
229
|
-
if (this.ws?.readyState === ws_1.default.OPEN) {
|
|
230
|
-
this.sendHeartbeat();
|
|
231
|
-
}
|
|
232
|
-
this.heartbeatInterval = setInterval(() => {
|
|
233
|
-
if (!this.lastHeartbeatAck) {
|
|
234
|
-
logger_1.logger.warn('Heartbeat ACK missing. Connection is zombie. Terminating to resume...');
|
|
235
|
-
this.ws?.terminate();
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
if (this.ws?.readyState !== ws_1.default.OPEN) {
|
|
239
|
-
logger_1.logger.warn('Heartbeat skipped: WebSocket is not open.');
|
|
240
|
-
this.cleanupHeartbeat();
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
this.lastHeartbeatAck = false;
|
|
244
|
-
this.sendHeartbeat();
|
|
245
|
-
}, this.heartbeatIntervalValue);
|
|
246
|
-
}, this.heartbeatIntervalValue * Math.random());
|
|
247
|
-
}
|
|
248
|
-
sendHeartbeat() {
|
|
249
|
-
if (this.ws?.readyState !== ws_1.default.OPEN)
|
|
250
|
-
return;
|
|
251
|
-
this.sendJson({ op: OpCode_1.OpCode.HEARTBEAT, d: this.sequence });
|
|
252
|
-
logger_1.logger.info(`Heartbeat sent with sequence ${this.sequence}.`);
|
|
253
|
-
}
|
|
254
|
-
identify() {
|
|
255
|
-
const identifyPayload = (0, identify_1.getIdentifyPayload)(this.token, this.options.properties);
|
|
256
|
-
this.sendJson({ op: OpCode_1.OpCode.IDENTIFY, d: identifyPayload });
|
|
257
|
-
logger_1.logger.info('Identify payload sent.');
|
|
258
|
-
}
|
|
259
|
-
resume() {
|
|
260
|
-
if (!this.sessionId || this.sequence === null) {
|
|
261
|
-
logger_1.logger.error('Attempted to resume without session ID or sequence. Falling back to identify.');
|
|
262
|
-
this.identify();
|
|
263
|
-
return;
|
|
264
|
-
}
|
|
265
|
-
const resumePayload = {
|
|
266
|
-
token: this.token,
|
|
267
|
-
session_id: this.sessionId,
|
|
268
|
-
seq: this.sequence,
|
|
269
|
-
};
|
|
270
|
-
this.sendJson({ op: OpCode_1.OpCode.RESUME, d: resumePayload });
|
|
271
|
-
logger_1.logger.info('Resume payload sent.');
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Send presence update payload to Gateway.
|
|
275
|
-
* @param {PresenceUpdatePayload} presence - Payload update status to send.
|
|
276
|
-
*/
|
|
277
|
-
sendActivity(presence) {
|
|
278
|
-
this.sendJson({ op: OpCode_1.OpCode.PRESENCE_UPDATE, d: presence });
|
|
279
|
-
logger_1.logger.info('Presence update sent.');
|
|
280
|
-
}
|
|
281
|
-
sendJson(data) {
|
|
282
|
-
if (this.ws?.readyState === ws_1.default.OPEN) {
|
|
283
|
-
this.ws.send(JSON.stringify(data));
|
|
284
|
-
}
|
|
285
|
-
else {
|
|
286
|
-
logger_1.logger.warn('Attempted to send data while WebSocket was not open.');
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Closes the WebSocket connection.
|
|
291
|
-
* @param {boolean} force If true, prevents any automatic reconnection attempts.
|
|
292
|
-
*/
|
|
293
|
-
close(force = false) {
|
|
294
|
-
if (force) {
|
|
295
|
-
logger_1.logger.info('Forcing permanent closure. Reconnects will be disabled.');
|
|
296
|
-
this.permanentClose = true;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
logger_1.logger.info('Closing connection manually...');
|
|
300
|
-
}
|
|
301
|
-
if (this.ws) {
|
|
302
|
-
if (this.ws.readyState === ws_1.default.OPEN) {
|
|
303
|
-
this.ws.close(1000, 'Client initiated closure');
|
|
304
|
-
}
|
|
305
|
-
else {
|
|
306
|
-
this.ws.terminate();
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
cleanupHeartbeat() {
|
|
311
|
-
if (this.heartbeatInterval) {
|
|
312
|
-
clearInterval(this.heartbeatInterval);
|
|
313
|
-
this.heartbeatInterval = null;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
shouldReconnect(code) {
|
|
317
|
-
const fatalErrorCodes = [4004, 4010, 4011, 4013, 4014];
|
|
318
|
-
if (fatalErrorCodes.includes(code)) {
|
|
319
|
-
logger_1.logger.error(`Fatal WebSocket error received (code: ${code}). Will not reconnect.`);
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
if (this.options.alwaysReconnect) {
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
|
-
return code !== 1000;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
exports.DiscordWebSocket = DiscordWebSocket;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OpCode = void 0;
|
|
4
|
-
var OpCode;
|
|
5
|
-
(function (OpCode) {
|
|
6
|
-
OpCode[OpCode["DISPATCH"] = 0] = "DISPATCH";
|
|
7
|
-
OpCode[OpCode["HEARTBEAT"] = 1] = "HEARTBEAT";
|
|
8
|
-
OpCode[OpCode["IDENTIFY"] = 2] = "IDENTIFY";
|
|
9
|
-
OpCode[OpCode["PRESENCE_UPDATE"] = 3] = "PRESENCE_UPDATE";
|
|
10
|
-
OpCode[OpCode["VOICE_STATE_UPDATE"] = 4] = "VOICE_STATE_UPDATE";
|
|
11
|
-
OpCode[OpCode["RESUME"] = 6] = "RESUME";
|
|
12
|
-
OpCode[OpCode["RECONNECT"] = 7] = "RECONNECT";
|
|
13
|
-
OpCode[OpCode["REQUEST_GUILD_MEMBERS"] = 8] = "REQUEST_GUILD_MEMBERS";
|
|
14
|
-
OpCode[OpCode["INVALID_SESSION"] = 9] = "INVALID_SESSION";
|
|
15
|
-
OpCode[OpCode["HELLO"] = 10] = "HELLO";
|
|
16
|
-
OpCode[OpCode["HEARTBEAT_ACK"] = 11] = "HEARTBEAT_ACK";
|
|
17
|
-
})(OpCode || (exports.OpCode = OpCode = {}));
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { IdentifyPayload } from './types';
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {object} ClientProperties
|
|
4
|
-
* @property {string} [os] - The operating system. (e.g., 'Windows', 'Android')
|
|
5
|
-
* @property {string} [browser] - The browser or client. (e.g., 'Discord Client', 'Discord Android')
|
|
6
|
-
* @property {string} [device] - The device. (e.g., 'Android16')
|
|
7
|
-
*/
|
|
8
|
-
export interface ClientProperties {
|
|
9
|
-
os?: string;
|
|
10
|
-
browser?: string;
|
|
11
|
-
device?: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function getIdentifyPayload(token: string, properties?: ClientProperties): IdentifyPayload;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getIdentifyPayload = getIdentifyPayload;
|
|
4
|
-
function getIdentifyPayload(token, properties) {
|
|
5
|
-
const defaultProperties = {
|
|
6
|
-
os: 'Windows',
|
|
7
|
-
browser: 'Discord Client',
|
|
8
|
-
device: 'hieuxyz©rpc',
|
|
9
|
-
};
|
|
10
|
-
return {
|
|
11
|
-
token: token,
|
|
12
|
-
capabilities: 65,
|
|
13
|
-
largeThreshold: 50,
|
|
14
|
-
properties: { ...defaultProperties, ...properties },
|
|
15
|
-
compress: true,
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { OpCode } from './OpCode';
|
|
2
|
-
export declare enum ActivityType {
|
|
3
|
-
Playing = 0,
|
|
4
|
-
Streaming = 1,
|
|
5
|
-
Listening = 2,
|
|
6
|
-
Watching = 3,
|
|
7
|
-
Custom = 4,
|
|
8
|
-
Competing = 5
|
|
9
|
-
}
|
|
10
|
-
export type ActivityTypeName = 'playing' | 'streaming' | 'listening' | 'watching' | 'custom' | 'competing';
|
|
11
|
-
export type SettableActivityType = ActivityType | ActivityTypeName | number;
|
|
12
|
-
export interface GatewayPayload {
|
|
13
|
-
op: OpCode;
|
|
14
|
-
d: any;
|
|
15
|
-
s?: number | null;
|
|
16
|
-
t?: string | null;
|
|
17
|
-
}
|
|
18
|
-
export interface IdentifyProperties {
|
|
19
|
-
os: string;
|
|
20
|
-
browser: string;
|
|
21
|
-
device: string;
|
|
22
|
-
}
|
|
23
|
-
export interface IdentifyPayload {
|
|
24
|
-
token: string;
|
|
25
|
-
capabilities: number;
|
|
26
|
-
largeThreshold: number;
|
|
27
|
-
properties: IdentifyProperties;
|
|
28
|
-
compress: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare enum UserFlags {
|
|
31
|
-
STAFF = 1,
|
|
32
|
-
PARTNER = 2,
|
|
33
|
-
HYPESQUAD = 4,
|
|
34
|
-
BUG_HUNTER_LEVEL_1 = 8,
|
|
35
|
-
HYPESQUAD_ONLINE_HOUSE_1 = 64,// Bravery
|
|
36
|
-
HYPESQUAD_ONLINE_HOUSE_2 = 128,// Brilliance
|
|
37
|
-
HYPESQUAD_ONLINE_HOUSE_3 = 256,// Balance
|
|
38
|
-
PREMIUM_EARLY_SUPPORTER = 512,
|
|
39
|
-
TEAM_PSEUDO_USER = 1024,
|
|
40
|
-
BUG_HUNTER_LEVEL_2 = 16384,
|
|
41
|
-
VERIFIED_BOT = 65536,
|
|
42
|
-
VERIFIED_DEVELOPER = 131072,
|
|
43
|
-
CERTIFIED_MODERATOR = 262144,
|
|
44
|
-
BOT_HTTP_INTERACTIONS = 524288,
|
|
45
|
-
ACTIVE_DEVELOPER = 4194304
|
|
46
|
-
}
|
|
47
|
-
export interface DiscordUser {
|
|
48
|
-
id: string;
|
|
49
|
-
username: string;
|
|
50
|
-
discriminator: string;
|
|
51
|
-
global_name?: string | null;
|
|
52
|
-
avatar?: string | null;
|
|
53
|
-
bot?: boolean;
|
|
54
|
-
system?: boolean;
|
|
55
|
-
mfa_enabled?: boolean;
|
|
56
|
-
banner?: string | null;
|
|
57
|
-
accent_color?: number | null;
|
|
58
|
-
locale?: string;
|
|
59
|
-
verified?: boolean;
|
|
60
|
-
email?: string | null;
|
|
61
|
-
flags?: number;
|
|
62
|
-
premium_type?: number;
|
|
63
|
-
public_flags?: number;
|
|
64
|
-
bio?: string;
|
|
65
|
-
phone?: string | null;
|
|
66
|
-
nsfw_allowed?: boolean;
|
|
67
|
-
pronouns?: string;
|
|
68
|
-
mobile?: boolean;
|
|
69
|
-
desktop?: boolean;
|
|
70
|
-
clan?: {
|
|
71
|
-
tag: string;
|
|
72
|
-
identity_guild_id: string;
|
|
73
|
-
badge: string;
|
|
74
|
-
identity_enabled?: boolean;
|
|
75
|
-
} | null;
|
|
76
|
-
primary_guild?: {
|
|
77
|
-
tag: string;
|
|
78
|
-
identity_guild_id: string;
|
|
79
|
-
badge: string;
|
|
80
|
-
identity_enabled?: boolean;
|
|
81
|
-
} | null;
|
|
82
|
-
purchased_flags?: number;
|
|
83
|
-
premium_usage_flags?: number;
|
|
84
|
-
premium?: boolean;
|
|
85
|
-
premium_state?: {
|
|
86
|
-
premium_subscription_type?: number;
|
|
87
|
-
premium_subscription_group_role?: number;
|
|
88
|
-
premium_source?: number;
|
|
89
|
-
} | null;
|
|
90
|
-
avatar_decoration_data?: {
|
|
91
|
-
asset: string;
|
|
92
|
-
sku_id: string;
|
|
93
|
-
expires_at: number | null;
|
|
94
|
-
} | null;
|
|
95
|
-
collectibles?: {
|
|
96
|
-
nameplate?: {
|
|
97
|
-
asset: string;
|
|
98
|
-
label: string;
|
|
99
|
-
sku_id: string;
|
|
100
|
-
palette?: string;
|
|
101
|
-
expires_at?: number | null;
|
|
102
|
-
};
|
|
103
|
-
} | null;
|
|
104
|
-
display_name_styles?: {
|
|
105
|
-
font_id?: number;
|
|
106
|
-
effect_id?: number;
|
|
107
|
-
colors?: number[];
|
|
108
|
-
} | null;
|
|
109
|
-
banner_color?: string | null;
|
|
110
|
-
age_verification_status?: number;
|
|
111
|
-
}
|
|
112
|
-
export interface Activity {
|
|
113
|
-
name: string;
|
|
114
|
-
type: number;
|
|
115
|
-
application_id?: string;
|
|
116
|
-
details?: string;
|
|
117
|
-
state?: string;
|
|
118
|
-
platform?: string;
|
|
119
|
-
instance?: boolean;
|
|
120
|
-
flags?: number;
|
|
121
|
-
sync_id?: string;
|
|
122
|
-
party?: {
|
|
123
|
-
id?: string;
|
|
124
|
-
size?: [number, number];
|
|
125
|
-
};
|
|
126
|
-
timestamps?: {
|
|
127
|
-
start?: number;
|
|
128
|
-
end?: number;
|
|
129
|
-
};
|
|
130
|
-
assets?: {
|
|
131
|
-
large_image?: string;
|
|
132
|
-
large_text?: string;
|
|
133
|
-
small_image?: string;
|
|
134
|
-
small_text?: string;
|
|
135
|
-
};
|
|
136
|
-
secrets?: {
|
|
137
|
-
join?: string;
|
|
138
|
-
spectate?: string;
|
|
139
|
-
match?: string;
|
|
140
|
-
};
|
|
141
|
-
buttons?: string[];
|
|
142
|
-
metadata?: {
|
|
143
|
-
button_urls?: string[];
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
export interface PresenceUpdatePayload {
|
|
147
|
-
since: number;
|
|
148
|
-
activities: Activity[];
|
|
149
|
-
status: 'online' | 'dnd' | 'idle' | 'invisible' | 'offline';
|
|
150
|
-
afk: boolean;
|
|
151
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserFlags = exports.ActivityType = void 0;
|
|
4
|
-
var ActivityType;
|
|
5
|
-
(function (ActivityType) {
|
|
6
|
-
ActivityType[ActivityType["Playing"] = 0] = "Playing";
|
|
7
|
-
ActivityType[ActivityType["Streaming"] = 1] = "Streaming";
|
|
8
|
-
ActivityType[ActivityType["Listening"] = 2] = "Listening";
|
|
9
|
-
ActivityType[ActivityType["Watching"] = 3] = "Watching";
|
|
10
|
-
ActivityType[ActivityType["Custom"] = 4] = "Custom";
|
|
11
|
-
ActivityType[ActivityType["Competing"] = 5] = "Competing";
|
|
12
|
-
})(ActivityType || (exports.ActivityType = ActivityType = {}));
|
|
13
|
-
var UserFlags;
|
|
14
|
-
(function (UserFlags) {
|
|
15
|
-
UserFlags[UserFlags["STAFF"] = 1] = "STAFF";
|
|
16
|
-
UserFlags[UserFlags["PARTNER"] = 2] = "PARTNER";
|
|
17
|
-
UserFlags[UserFlags["HYPESQUAD"] = 4] = "HYPESQUAD";
|
|
18
|
-
UserFlags[UserFlags["BUG_HUNTER_LEVEL_1"] = 8] = "BUG_HUNTER_LEVEL_1";
|
|
19
|
-
UserFlags[UserFlags["HYPESQUAD_ONLINE_HOUSE_1"] = 64] = "HYPESQUAD_ONLINE_HOUSE_1";
|
|
20
|
-
UserFlags[UserFlags["HYPESQUAD_ONLINE_HOUSE_2"] = 128] = "HYPESQUAD_ONLINE_HOUSE_2";
|
|
21
|
-
UserFlags[UserFlags["HYPESQUAD_ONLINE_HOUSE_3"] = 256] = "HYPESQUAD_ONLINE_HOUSE_3";
|
|
22
|
-
UserFlags[UserFlags["PREMIUM_EARLY_SUPPORTER"] = 512] = "PREMIUM_EARLY_SUPPORTER";
|
|
23
|
-
UserFlags[UserFlags["TEAM_PSEUDO_USER"] = 1024] = "TEAM_PSEUDO_USER";
|
|
24
|
-
UserFlags[UserFlags["BUG_HUNTER_LEVEL_2"] = 16384] = "BUG_HUNTER_LEVEL_2";
|
|
25
|
-
UserFlags[UserFlags["VERIFIED_BOT"] = 65536] = "VERIFIED_BOT";
|
|
26
|
-
UserFlags[UserFlags["VERIFIED_DEVELOPER"] = 131072] = "VERIFIED_DEVELOPER";
|
|
27
|
-
UserFlags[UserFlags["CERTIFIED_MODERATOR"] = 262144] = "CERTIFIED_MODERATOR";
|
|
28
|
-
UserFlags[UserFlags["BOT_HTTP_INTERACTIONS"] = 524288] = "BOT_HTTP_INTERACTIONS";
|
|
29
|
-
UserFlags[UserFlags["ACTIVE_DEVELOPER"] = 4194304] = "ACTIVE_DEVELOPER";
|
|
30
|
-
})(UserFlags || (exports.UserFlags = UserFlags = {}));
|