@hieuxyz/rpc 1.1.0 → 1.2.0
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/README.md +56 -22
- package/dist/hieuxyz/Client.d.ts +30 -5
- package/dist/hieuxyz/Client.js +146 -5
- package/dist/hieuxyz/gateway/DiscordWebSocket.d.ts +15 -6
- package/dist/hieuxyz/gateway/DiscordWebSocket.js +72 -36
- package/dist/hieuxyz/gateway/entities/identify.d.ts +12 -1
- package/dist/hieuxyz/gateway/entities/identify.js +7 -6
- package/dist/hieuxyz/gateway/entities/types.d.ts +95 -5
- package/dist/hieuxyz/gateway/entities/types.js +19 -1
- package/dist/hieuxyz/rpc/HieuxyzRPC.d.ts +75 -17
- package/dist/hieuxyz/rpc/HieuxyzRPC.js +144 -21
- package/dist/hieuxyz/rpc/ImageService.d.ts +11 -0
- package/dist/hieuxyz/rpc/ImageService.js +17 -0
- package/dist/hieuxyz/rpc/RpcImage.d.ts +13 -0
- package/dist/hieuxyz/rpc/RpcImage.js +22 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/package.json +14 -6
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HieuxyzRPC = void 0;
|
|
3
|
+
exports.HieuxyzRPC = exports.ActivityFlags = void 0;
|
|
4
4
|
const types_1 = require("../gateway/entities/types");
|
|
5
5
|
const RpcImage_1 = require("./RpcImage");
|
|
6
6
|
const logger_1 = require("../utils/logger");
|
|
7
|
+
/**
|
|
8
|
+
* Flags for activities, used with `.setFlags()`.
|
|
9
|
+
* @enum {number}
|
|
10
|
+
*/
|
|
11
|
+
var ActivityFlags;
|
|
12
|
+
(function (ActivityFlags) {
|
|
13
|
+
ActivityFlags[ActivityFlags["INSTANCE"] = 1] = "INSTANCE";
|
|
14
|
+
ActivityFlags[ActivityFlags["JOIN"] = 2] = "JOIN";
|
|
15
|
+
ActivityFlags[ActivityFlags["SPECTATE"] = 4] = "SPECTATE";
|
|
16
|
+
ActivityFlags[ActivityFlags["JOIN_REQUEST"] = 8] = "JOIN_REQUEST";
|
|
17
|
+
ActivityFlags[ActivityFlags["SYNC"] = 16] = "SYNC";
|
|
18
|
+
ActivityFlags[ActivityFlags["PLAY"] = 32] = "PLAY";
|
|
19
|
+
})(ActivityFlags || (exports.ActivityFlags = ActivityFlags = {}));
|
|
7
20
|
/**
|
|
8
21
|
* Class built for creating and managing Discord Rich Presence states.
|
|
9
22
|
*/
|
|
@@ -13,7 +26,7 @@ class HieuxyzRPC {
|
|
|
13
26
|
activity = {};
|
|
14
27
|
assets = {};
|
|
15
28
|
status = 'online';
|
|
16
|
-
applicationId = '1416676323459469363';
|
|
29
|
+
applicationId = '1416676323459469363';
|
|
17
30
|
platform = 'desktop';
|
|
18
31
|
/**
|
|
19
32
|
* Cache for resolved image assets to avoid re-uploading or re-fetching.
|
|
@@ -22,11 +35,58 @@ class HieuxyzRPC {
|
|
|
22
35
|
*/
|
|
23
36
|
resolvedAssetsCache = new Map();
|
|
24
37
|
renewalInterval = null;
|
|
38
|
+
/**
|
|
39
|
+
* Cache for Application Assets (Bot Assets).
|
|
40
|
+
* Map<ApplicationID, Map<AssetName, AssetID>>
|
|
41
|
+
*/
|
|
42
|
+
applicationAssetsCache = new Map();
|
|
25
43
|
constructor(websocket, imageService) {
|
|
26
44
|
this.websocket = websocket;
|
|
27
45
|
this.imageService = imageService;
|
|
28
46
|
this.startBackgroundRenewal();
|
|
29
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the URL of the large image asset, if available.
|
|
50
|
+
* @type {string | null}
|
|
51
|
+
* @readonly
|
|
52
|
+
*/
|
|
53
|
+
get largeImageUrl() {
|
|
54
|
+
if (!this.assets.large_image)
|
|
55
|
+
return null;
|
|
56
|
+
const cacheKey = this.assets.large_image.getCacheKey();
|
|
57
|
+
const resolvedAsset = this.resolvedAssetsCache.get(cacheKey);
|
|
58
|
+
return resolvedAsset ? this._resolveAssetUrl(resolvedAsset) : null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the URL of the small image asset, if available.
|
|
62
|
+
* @type {string | null}
|
|
63
|
+
* @readonly
|
|
64
|
+
*/
|
|
65
|
+
get smallImageUrl() {
|
|
66
|
+
if (!this.assets.small_image)
|
|
67
|
+
return null;
|
|
68
|
+
const cacheKey = this.assets.small_image.getCacheKey();
|
|
69
|
+
const resolvedAsset = this.resolvedAssetsCache.get(cacheKey);
|
|
70
|
+
return resolvedAsset ? this._resolveAssetUrl(resolvedAsset) : null;
|
|
71
|
+
}
|
|
72
|
+
_resolveAssetUrl(assetKey) {
|
|
73
|
+
if (assetKey.startsWith('mp:')) {
|
|
74
|
+
return `https://media.discordapp.net/${assetKey.substring(3)}`;
|
|
75
|
+
}
|
|
76
|
+
if (assetKey.startsWith('spotify:')) {
|
|
77
|
+
return `https://i.scdn.co/image/${assetKey.substring(8)}`;
|
|
78
|
+
}
|
|
79
|
+
if (assetKey.startsWith('youtube:')) {
|
|
80
|
+
return `https://i.ytimg.com/vi/${assetKey.substring(8)}/hqdefault.jpg`;
|
|
81
|
+
}
|
|
82
|
+
if (assetKey.startsWith('twitch:')) {
|
|
83
|
+
return `https://static-cdn.jtvnw.net/previews-ttv/live_user_${assetKey.substring(7)}.png`;
|
|
84
|
+
}
|
|
85
|
+
if (this.applicationId && !assetKey.startsWith('http')) {
|
|
86
|
+
return `https://cdn.discordapp.com/app-assets/${this.applicationId}/${assetKey}.png`;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
30
90
|
_toRpcImage(source) {
|
|
31
91
|
if (typeof source !== 'string') {
|
|
32
92
|
return source;
|
|
@@ -50,6 +110,9 @@ class HieuxyzRPC {
|
|
|
50
110
|
if (source.startsWith('attachments/') || source.startsWith('external/')) {
|
|
51
111
|
return new RpcImage_1.DiscordImage(source);
|
|
52
112
|
}
|
|
113
|
+
if (/^[a-zA-Z0-9_]+$/.test(source) && !/^\d{17,20}$/.test(source)) {
|
|
114
|
+
return new RpcImage_1.ApplicationImage(source);
|
|
115
|
+
}
|
|
53
116
|
return new RpcImage_1.RawImage(source);
|
|
54
117
|
}
|
|
55
118
|
cleanupNulls(obj) {
|
|
@@ -60,7 +123,7 @@ class HieuxyzRPC {
|
|
|
60
123
|
}
|
|
61
124
|
/**
|
|
62
125
|
* Name the operation (first line of RPC).
|
|
63
|
-
* @param name - Name to display.
|
|
126
|
+
* @param {string} name - Name to display.
|
|
64
127
|
* @returns {this}
|
|
65
128
|
*/
|
|
66
129
|
setName(name) {
|
|
@@ -69,7 +132,7 @@ class HieuxyzRPC {
|
|
|
69
132
|
}
|
|
70
133
|
/**
|
|
71
134
|
* Set details for the operation (second line of RPC).
|
|
72
|
-
* @param details - Details to display.
|
|
135
|
+
* @param {string} details - Details to display.
|
|
73
136
|
* @returns {this}
|
|
74
137
|
*/
|
|
75
138
|
setDetails(details) {
|
|
@@ -78,7 +141,7 @@ class HieuxyzRPC {
|
|
|
78
141
|
}
|
|
79
142
|
/**
|
|
80
143
|
* Set the state for the operation (third line of the RPC).
|
|
81
|
-
* @param state - State to display.
|
|
144
|
+
* @param {string} state - State to display.
|
|
82
145
|
* @returns {this}
|
|
83
146
|
*/
|
|
84
147
|
setState(state) {
|
|
@@ -87,7 +150,7 @@ class HieuxyzRPC {
|
|
|
87
150
|
}
|
|
88
151
|
/**
|
|
89
152
|
* Set the activity type.
|
|
90
|
-
* @param type - The type of activity (e.g. 0, 'playing', or ActivityType.Playing).
|
|
153
|
+
* @param {SettableActivityType} type - The type of activity (e.g. 0, 'playing', or ActivityType.Playing).
|
|
91
154
|
* @returns {this}
|
|
92
155
|
*/
|
|
93
156
|
setType(type) {
|
|
@@ -109,8 +172,8 @@ class HieuxyzRPC {
|
|
|
109
172
|
}
|
|
110
173
|
/**
|
|
111
174
|
* Set a start and/or end timestamp for the activity.
|
|
112
|
-
* @param start - Unix timestamp (milliseconds) for start time.
|
|
113
|
-
* @param end - Unix timestamp (milliseconds) for the end time.
|
|
175
|
+
* @param {number} [start] - Unix timestamp (milliseconds) for start time.
|
|
176
|
+
* @param {number} [end] - Unix timestamp (milliseconds) for the end time.
|
|
114
177
|
* @returns {this}
|
|
115
178
|
*/
|
|
116
179
|
setTimestamps(start, end) {
|
|
@@ -119,8 +182,8 @@ class HieuxyzRPC {
|
|
|
119
182
|
}
|
|
120
183
|
/**
|
|
121
184
|
* Set party information for the activity.
|
|
122
|
-
* @param currentSize - Current number of players.
|
|
123
|
-
* @param maxSize - Maximum number of players.
|
|
185
|
+
* @param {number} currentSize - Current number of players.
|
|
186
|
+
* @param {number} maxSize - Maximum number of players.
|
|
124
187
|
* @returns {this}
|
|
125
188
|
*/
|
|
126
189
|
setParty(currentSize, maxSize) {
|
|
@@ -129,8 +192,8 @@ class HieuxyzRPC {
|
|
|
129
192
|
}
|
|
130
193
|
/**
|
|
131
194
|
* Set large image and its caption text.
|
|
132
|
-
* @param source - Image source (URL, asset key, or RpcImage object).
|
|
133
|
-
* @param text - Text displayed when hovering over image.
|
|
195
|
+
* @param {string | RpcImage} source - Image source (URL, asset key, Asset Name or RpcImage object).
|
|
196
|
+
* @param {string} [text] - Text displayed when hovering over image.
|
|
134
197
|
* @returns {this}
|
|
135
198
|
*/
|
|
136
199
|
setLargeImage(source, text) {
|
|
@@ -141,8 +204,8 @@ class HieuxyzRPC {
|
|
|
141
204
|
}
|
|
142
205
|
/**
|
|
143
206
|
* Set the small image and its caption text.
|
|
144
|
-
* @param source - Image source (URL, asset key, or RpcImage object).
|
|
145
|
-
* @param text - Text displayed when hovering over image.
|
|
207
|
+
* @param {string | RpcImage} source - Image source (URL, asset key, Asset Name or RpcImage object).
|
|
208
|
+
* @param {string} [text] - Text displayed when hovering over image.
|
|
146
209
|
* @returns {this}
|
|
147
210
|
*/
|
|
148
211
|
setSmallImage(source, text) {
|
|
@@ -153,7 +216,7 @@ class HieuxyzRPC {
|
|
|
153
216
|
}
|
|
154
217
|
/**
|
|
155
218
|
* Set clickable buttons for RPC (up to 2).
|
|
156
|
-
* @param buttons - An array of button objects
|
|
219
|
+
* @param {RpcButton[]} buttons - An array of button objects, each with a `label` and `url`.
|
|
157
220
|
* @returns {this}
|
|
158
221
|
*/
|
|
159
222
|
setButtons(buttons) {
|
|
@@ -162,22 +225,49 @@ class HieuxyzRPC {
|
|
|
162
225
|
this.activity.metadata = { button_urls: validButtons.map((b) => b.url) };
|
|
163
226
|
return this;
|
|
164
227
|
}
|
|
228
|
+
/**
|
|
229
|
+
* Set secrets for joining, spectating, and matching games.
|
|
230
|
+
* @param {RpcSecrets} secrets - An object with join, spectate, and/or match secrets.
|
|
231
|
+
* @returns {this}
|
|
232
|
+
*/
|
|
233
|
+
setSecrets(secrets) {
|
|
234
|
+
this.activity.secrets = secrets;
|
|
235
|
+
return this;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Set the sync_id, typically used for Spotify track synchronization.
|
|
239
|
+
* @param {string} syncId - The synchronization ID.
|
|
240
|
+
* @returns {this}
|
|
241
|
+
*/
|
|
242
|
+
setSyncId(syncId) {
|
|
243
|
+
this.activity.sync_id = syncId;
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Set activity flags. Use the ActivityFlags enum for convenience.
|
|
248
|
+
* @param {number} flags - A number representing the bitwise flags.
|
|
249
|
+
* @returns {this}
|
|
250
|
+
*/
|
|
251
|
+
setFlags(flags) {
|
|
252
|
+
this.activity.flags = flags;
|
|
253
|
+
return this;
|
|
254
|
+
}
|
|
165
255
|
/**
|
|
166
256
|
* Set custom application ID for RPC.
|
|
167
|
-
* @param id - Discord app ID (must be an 18 or 19 digit number string).
|
|
257
|
+
* @param {string} id - Discord app ID (must be an 18 or 19 digit number string).
|
|
168
258
|
* @throws {Error} If ID is invalid.
|
|
169
259
|
* @returns {this}
|
|
170
260
|
*/
|
|
171
261
|
setApplicationId(id) {
|
|
172
|
-
if (!/^\d{
|
|
173
|
-
throw new Error('The app ID must be
|
|
262
|
+
if (!/^\d{17,20}$/.test(id)) {
|
|
263
|
+
throw new Error('The app ID must be a valid number string (17-20 digits).');
|
|
174
264
|
}
|
|
175
265
|
this.applicationId = id;
|
|
176
266
|
return this;
|
|
177
267
|
}
|
|
178
268
|
/**
|
|
179
269
|
* Set the user's status (e.g. online, idle, dnd).
|
|
180
|
-
* @param status - Desired state.
|
|
270
|
+
* @param {'online' | 'dnd' | 'idle' | 'invisible' | 'offline'} status - Desired state.
|
|
181
271
|
* @returns {this}
|
|
182
272
|
*/
|
|
183
273
|
setStatus(status) {
|
|
@@ -186,7 +276,7 @@ class HieuxyzRPC {
|
|
|
186
276
|
}
|
|
187
277
|
/**
|
|
188
278
|
* Set the platform on which the activity is running.
|
|
189
|
-
* @param platform - Platform (e.g. 'desktop', 'xbox').
|
|
279
|
+
* @param {DiscordPlatform} platform - Platform (e.g. 'desktop', 'xbox').
|
|
190
280
|
* @returns {this}
|
|
191
281
|
*/
|
|
192
282
|
setPlatform(platform) {
|
|
@@ -195,7 +285,7 @@ class HieuxyzRPC {
|
|
|
195
285
|
}
|
|
196
286
|
/**
|
|
197
287
|
* Marks the activity as a joinable instance for the game.
|
|
198
|
-
* @param instance - Whether this activity is a specific instance.
|
|
288
|
+
* @param {boolean} instance - Whether this activity is a specific instance.
|
|
199
289
|
* @returns {this}
|
|
200
290
|
*/
|
|
201
291
|
setInstance(instance) {
|
|
@@ -223,6 +313,10 @@ class HieuxyzRPC {
|
|
|
223
313
|
this.activity.metadata = undefined;
|
|
224
314
|
return this;
|
|
225
315
|
}
|
|
316
|
+
clearSecrets() {
|
|
317
|
+
this.activity.secrets = undefined;
|
|
318
|
+
return this;
|
|
319
|
+
}
|
|
226
320
|
clearInstance() {
|
|
227
321
|
this.activity.instance = undefined;
|
|
228
322
|
return this;
|
|
@@ -288,16 +382,45 @@ class HieuxyzRPC {
|
|
|
288
382
|
logger_1.logger.info('Stopped background asset renewal process.');
|
|
289
383
|
}
|
|
290
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Ensure assets are fetched for the current application ID.
|
|
387
|
+
*/
|
|
388
|
+
async ensureAppAssetsLoaded() {
|
|
389
|
+
if (!this.applicationAssetsCache.has(this.applicationId)) {
|
|
390
|
+
logger_1.logger.info(`Fetching assets for Application ID: ${this.applicationId}...`);
|
|
391
|
+
const assets = await this.imageService.fetchApplicationAssets(this.applicationId);
|
|
392
|
+
const assetMap = new Map();
|
|
393
|
+
assets.forEach((asset) => {
|
|
394
|
+
assetMap.set(asset.name, asset.id);
|
|
395
|
+
});
|
|
396
|
+
this.applicationAssetsCache.set(this.applicationId, assetMap);
|
|
397
|
+
logger_1.logger.info(`Loaded ${assets.length} assets for Application ID: ${this.applicationId}.`);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
291
400
|
async resolveImage(image) {
|
|
292
401
|
if (!image)
|
|
293
402
|
return undefined;
|
|
294
403
|
const cacheKey = image.getCacheKey();
|
|
404
|
+
if (cacheKey.startsWith('app_asset:')) {
|
|
405
|
+
await this.ensureAppAssetsLoaded();
|
|
406
|
+
const assetName = cacheKey.substring('app_asset:'.length);
|
|
407
|
+
const appAssets = this.applicationAssetsCache.get(this.applicationId);
|
|
408
|
+
const assetId = appAssets?.get(assetName);
|
|
409
|
+
if (!assetId) {
|
|
410
|
+
logger_1.logger.warn(`Asset with name "${assetName}" not found for Application ID ${this.applicationId}.`);
|
|
411
|
+
return undefined;
|
|
412
|
+
}
|
|
413
|
+
return assetId;
|
|
414
|
+
}
|
|
295
415
|
const cachedAsset = this.resolvedAssetsCache.get(cacheKey);
|
|
296
416
|
if (cachedAsset) {
|
|
297
417
|
return await this.renewAssetIfNeeded(cacheKey, cachedAsset);
|
|
298
418
|
}
|
|
299
419
|
const resolvedAsset = await image.resolve(this.imageService);
|
|
300
420
|
if (resolvedAsset) {
|
|
421
|
+
if (resolvedAsset.startsWith('app_asset:')) {
|
|
422
|
+
return this.resolveImage(image);
|
|
423
|
+
}
|
|
301
424
|
this.resolvedAssetsCache.set(cacheKey, resolvedAsset);
|
|
302
425
|
}
|
|
303
426
|
return resolvedAsset;
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
export interface DiscordAsset {
|
|
2
|
+
id: string;
|
|
3
|
+
type: number;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
1
6
|
/**
|
|
2
7
|
* A service to handle external image proxying and local image uploading.
|
|
3
8
|
* Interact with a backend API service to manage image assets.
|
|
@@ -28,4 +33,10 @@ export declare class ImageService {
|
|
|
28
33
|
* @returns {Promise<string | undefined>} The new asset key or undefined if it failed.
|
|
29
34
|
*/
|
|
30
35
|
renewImage(assetId: string): Promise<string | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* Fetch all assets for a specific Discord Application.
|
|
38
|
+
* @param applicationId - The ID of the application.
|
|
39
|
+
* @returns {Promise<DiscordAsset[]>} List of assets (id, name, type).
|
|
40
|
+
*/
|
|
41
|
+
fetchApplicationAssets(applicationId: string): Promise<DiscordAsset[]>;
|
|
31
42
|
}
|
|
@@ -121,5 +121,22 @@ class ImageService {
|
|
|
121
121
|
}
|
|
122
122
|
return undefined;
|
|
123
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Fetch all assets for a specific Discord Application.
|
|
126
|
+
* @param applicationId - The ID of the application.
|
|
127
|
+
* @returns {Promise<DiscordAsset[]>} List of assets (id, name, type).
|
|
128
|
+
*/
|
|
129
|
+
async fetchApplicationAssets(applicationId) {
|
|
130
|
+
try {
|
|
131
|
+
const url = `https://discord.com/api/v9/oauth2/applications/${applicationId}/assets`;
|
|
132
|
+
const response = await axios_1.default.get(url);
|
|
133
|
+
return response.data;
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
const err = error;
|
|
137
|
+
logger_1.logger.error(`Failed to fetch assets for application ${applicationId}: ${err.message}. Ensure the App ID is correct.`);
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
}
|
|
124
141
|
}
|
|
125
142
|
exports.ImageService = ImageService;
|
|
@@ -54,3 +54,16 @@ export declare class RawImage extends RpcImage {
|
|
|
54
54
|
resolve(__imageService: ImageService): Promise<string | undefined>;
|
|
55
55
|
getCacheKey(): string;
|
|
56
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Represents an asset uploaded to the Discord Application (Bot Assets).
|
|
59
|
+
* It will resolve the asset ID by matching the asset name.
|
|
60
|
+
*/
|
|
61
|
+
export declare class ApplicationImage extends RpcImage {
|
|
62
|
+
assetName: string;
|
|
63
|
+
/**
|
|
64
|
+
* @param assetName The name of the asset as defined in the Discord Developer Portal.
|
|
65
|
+
*/
|
|
66
|
+
constructor(assetName: string);
|
|
67
|
+
resolve(__imageService: ImageService): Promise<string | undefined>;
|
|
68
|
+
getCacheKey(): string;
|
|
69
|
+
}
|
|
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.RawImage = exports.LocalImage = exports.ExternalImage = exports.DiscordImage = exports.RpcImage = void 0;
|
|
36
|
+
exports.ApplicationImage = exports.RawImage = exports.LocalImage = exports.ExternalImage = exports.DiscordImage = exports.RpcImage = void 0;
|
|
37
37
|
const path = __importStar(require("path"));
|
|
38
38
|
/**
|
|
39
39
|
* Base abstract class for all RPC image types.
|
|
@@ -113,3 +113,24 @@ class RawImage extends RpcImage {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
exports.RawImage = RawImage;
|
|
116
|
+
/**
|
|
117
|
+
* Represents an asset uploaded to the Discord Application (Bot Assets).
|
|
118
|
+
* It will resolve the asset ID by matching the asset name.
|
|
119
|
+
*/
|
|
120
|
+
class ApplicationImage extends RpcImage {
|
|
121
|
+
assetName;
|
|
122
|
+
/**
|
|
123
|
+
* @param assetName The name of the asset as defined in the Discord Developer Portal.
|
|
124
|
+
*/
|
|
125
|
+
constructor(assetName) {
|
|
126
|
+
super();
|
|
127
|
+
this.assetName = assetName;
|
|
128
|
+
}
|
|
129
|
+
async resolve(__imageService) {
|
|
130
|
+
return `app_asset:${this.assetName}`;
|
|
131
|
+
}
|
|
132
|
+
getCacheKey() {
|
|
133
|
+
return `app_asset:${this.assetName}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.ApplicationImage = ApplicationImage;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { Client, ClientOptions } from './hieuxyz/Client';
|
|
|
2
2
|
export { DiscordWebSocket } from './hieuxyz/gateway/DiscordWebSocket';
|
|
3
3
|
export { HieuxyzRPC } from './hieuxyz/rpc/HieuxyzRPC';
|
|
4
4
|
export { ImageService } from './hieuxyz/rpc/ImageService';
|
|
5
|
-
export { RpcImage, DiscordImage, ExternalImage, LocalImage, RawImage } from './hieuxyz/rpc/RpcImage';
|
|
5
|
+
export { RpcImage, DiscordImage, ExternalImage, LocalImage, RawImage, ApplicationImage } from './hieuxyz/rpc/RpcImage';
|
|
6
6
|
export { logger } from './hieuxyz/utils/logger';
|
|
7
7
|
export * from './hieuxyz/gateway/entities/types';
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.logger = exports.RawImage = exports.LocalImage = exports.ExternalImage = exports.DiscordImage = exports.RpcImage = exports.ImageService = exports.HieuxyzRPC = exports.DiscordWebSocket = exports.Client = void 0;
|
|
17
|
+
exports.logger = exports.ApplicationImage = exports.RawImage = exports.LocalImage = exports.ExternalImage = exports.DiscordImage = exports.RpcImage = exports.ImageService = exports.HieuxyzRPC = exports.DiscordWebSocket = exports.Client = void 0;
|
|
18
18
|
var Client_1 = require("./hieuxyz/Client");
|
|
19
19
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
|
|
20
20
|
var DiscordWebSocket_1 = require("./hieuxyz/gateway/DiscordWebSocket");
|
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "DiscordImage", { enumerable: true, get: function
|
|
|
29
29
|
Object.defineProperty(exports, "ExternalImage", { enumerable: true, get: function () { return RpcImage_1.ExternalImage; } });
|
|
30
30
|
Object.defineProperty(exports, "LocalImage", { enumerable: true, get: function () { return RpcImage_1.LocalImage; } });
|
|
31
31
|
Object.defineProperty(exports, "RawImage", { enumerable: true, get: function () { return RpcImage_1.RawImage; } });
|
|
32
|
+
Object.defineProperty(exports, "ApplicationImage", { enumerable: true, get: function () { return RpcImage_1.ApplicationImage; } });
|
|
32
33
|
var logger_1 = require("./hieuxyz/utils/logger");
|
|
33
34
|
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
34
35
|
__exportStar(require("./hieuxyz/gateway/entities/types"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hieuxyz/rpc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A Discord Rich Presence library for Node.js",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"lint:fix": "eslint \"src/**/*.ts\" --fix",
|
|
17
17
|
"format": "prettier --write \"src/**/*.ts\" \"examples/**/*.ts\""
|
|
18
18
|
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/hieuxyz00/hieuxyz_rpc.git"
|
|
22
|
+
},
|
|
19
23
|
"keywords": [
|
|
20
24
|
"discord",
|
|
21
25
|
"rpc",
|
|
@@ -23,19 +27,23 @@
|
|
|
23
27
|
],
|
|
24
28
|
"author": "hieuxyz",
|
|
25
29
|
"license": "ISC",
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/hieuxyz00/hieuxyz_rpc/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/hieuxyz00/hieuxyz_rpc#readme",
|
|
26
34
|
"dependencies": {
|
|
27
|
-
"axios": "^1.
|
|
35
|
+
"axios": "^1.13.2",
|
|
28
36
|
"ws": "^8.18.3"
|
|
29
37
|
},
|
|
30
38
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^25.0.3",
|
|
32
40
|
"@types/ws": "^8.18.1",
|
|
33
|
-
"eslint": "^9.
|
|
41
|
+
"eslint": "^9.39.2",
|
|
34
42
|
"eslint-config-prettier": "^10.1.8",
|
|
35
43
|
"eslint-plugin-prettier": "^5.5.4",
|
|
36
|
-
"prettier": "^3.
|
|
44
|
+
"prettier": "^3.7.4",
|
|
37
45
|
"ts-node": "^10.9.2",
|
|
38
46
|
"typescript": "^5.9.3",
|
|
39
|
-
"typescript-eslint": "^8.
|
|
47
|
+
"typescript-eslint": "^8.51.0"
|
|
40
48
|
}
|
|
41
49
|
}
|