@ejercito-fam/habbo-api 1.0.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.
@@ -0,0 +1,448 @@
1
+ import { Json, type FetchResult } from '@skyra/safe-fetch';
2
+ import { HabboGroupType } from 'routes/groups.js';
3
+ import { BaseAPI, type APIOptions } from './base.js';
4
+
5
+ export class UsersAPI extends BaseAPI {
6
+ /**
7
+ * Get a user by its username
8
+ *
9
+ * @param username - The username to search a Habbo user by
10
+ * @param options - The options for the API call
11
+ */
12
+ public getByUsername(username: string, options?: APIOptions): Promise<FetchResult<HabboUser>> {
13
+ const url = this.formatURL('/api/public/users');
14
+ url.searchParams.set('name', username);
15
+ return Json<HabboUser>(this.fetch(url, options));
16
+ }
17
+
18
+ /**
19
+ * Get a user by its ID
20
+ *
21
+ * @param uniqueId - The ID to search a Habbo user by
22
+ * @param options - The options for the API call
23
+ */
24
+ public getByUniqueId(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUser>> {
25
+ const url = this.formatURL(`/api/public/users/${uniqueId}`);
26
+ return Json<HabboUser>(this.fetch(url, options));
27
+ }
28
+
29
+ /**
30
+ * Get a user's friends
31
+ *
32
+ * @param uniqueId - The ID to search a Habbo user by
33
+ * @param options - The options for the API call
34
+ */
35
+ public getUserFriends(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserFriend[]>> {
36
+ const url = this.formatURL(`/api/public/users/${uniqueId}/friends`);
37
+ return Json<HabboUserFriend[]>(this.fetch(url, options));
38
+ }
39
+
40
+ /**
41
+ * Get a user's groups
42
+ *
43
+ * @param uniqueId - The ID to search a Habbo user by
44
+ * @param options - The options for the API call
45
+ */
46
+ public getUserGroups(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserGroup[]>> {
47
+ const url = this.formatURL(`/api/public/users/${uniqueId}/groups`);
48
+ return Json<HabboUserGroup[]>(this.fetch(url, options));
49
+ }
50
+
51
+ /**
52
+ * Get a user's rooms
53
+ *
54
+ * @param uniqueId - The ID to search a Habbo user by
55
+ * @param options - The options for the API call
56
+ */
57
+ public getUserRooms(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserRoom[]>> {
58
+ const url = this.formatURL(`/api/public/users/${uniqueId}/rooms`);
59
+ return Json<HabboUserRoom[]>(this.fetch(url, options));
60
+ }
61
+
62
+ /**
63
+ * Get a user's badges
64
+ *
65
+ * @param uniqueId - The ID to search a Habbo user by
66
+ * @param options - The options for the API call
67
+ */
68
+ public getUserBadges(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserBadge[]>> {
69
+ const url = this.formatURL(`/api/public/users/${uniqueId}/badges`);
70
+ return Json<HabboUserBadge[]>(this.fetch(url, options));
71
+ }
72
+
73
+ /**
74
+ * Get a user's profile
75
+ *
76
+ * @param uniqueId - The ID to search a Habbo user by
77
+ * @param options - The options for the API call
78
+ */
79
+ public getUserProfile(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserProfile>> {
80
+ const url = this.formatURL(`/api/public/users/${uniqueId}/profile`);
81
+ return Json<HabboUserProfile>(this.fetch(url, options));
82
+ }
83
+
84
+ /**
85
+ * Get a user's photos
86
+ *
87
+ * @param uniqueId - The ID to search a Habbo user by
88
+ * @param options - The options for the API call
89
+ */
90
+ public getUserPhotos(uniqueId: string, options?: APIOptions): Promise<FetchResult<HabboUserPhotos[]>> {
91
+ const url = this.formatURL(`/extradata/public/users/${uniqueId}/photos`);
92
+ return Json<HabboUserPhotos[]>(this.fetch(url, options));
93
+ }
94
+ }
95
+
96
+ export type HabboUserId = `hh${string}-${string}`;
97
+
98
+ /**
99
+ * Represents a Habbo user.
100
+ */
101
+ export interface HabboUser {
102
+ /**
103
+ * The unique identifier of the user.
104
+ */
105
+ uniqueId: HabboUserId;
106
+ /**
107
+ * The name of the user.
108
+ */
109
+ name: string;
110
+ /**
111
+ * The figure string of the user.
112
+ */
113
+ figureString: string;
114
+ /**
115
+ * The motto of the user.
116
+ */
117
+ motto: string;
118
+ /**
119
+ * Indicates whether the user is online.
120
+ */
121
+ online: boolean;
122
+ /**
123
+ * The last access time of the user.
124
+ */
125
+ lastAccessTime: string;
126
+ /**
127
+ * The date when the user became a member.
128
+ */
129
+ memberSince: string;
130
+ /**
131
+ * Indicates whether the user's profile is visible.
132
+ */
133
+ profileVisible: boolean;
134
+ /**
135
+ * The current level of the user.
136
+ */
137
+ currentLevel: number;
138
+ /**
139
+ * The percentage of the current level completed by the user.
140
+ */
141
+ currentLevelCompletePercent: number;
142
+ /**
143
+ * The total experience points of the user.
144
+ */
145
+ totalExperience: number;
146
+ /**
147
+ * The number of star gems the user has.
148
+ */
149
+ starGemCount: number;
150
+ /**
151
+ * The badges selected by the user.
152
+ */
153
+ selectedBadges: HabboUserSelectedBadge[];
154
+ }
155
+
156
+ /**
157
+ * Represents a room owned by a Habbo user.
158
+ */
159
+ export interface HabboUserRoom {
160
+ /**
161
+ * The unique identifier of the room.
162
+ */
163
+ id: number;
164
+ /**
165
+ * The name of the room.
166
+ */
167
+ name: string;
168
+ /**
169
+ * The description of the room.
170
+ */
171
+ description: string;
172
+ /**
173
+ * The creation time of the room.
174
+ */
175
+ creationTime: string;
176
+ /**
177
+ * The unique identifier of the Habbo group associated with the room.
178
+ */
179
+ habboGroupId: string;
180
+ /**
181
+ * The tags associated with the room.
182
+ */
183
+ tags: string[];
184
+ /**
185
+ * The maximum number of visitors allowed in the room.
186
+ */
187
+ maximumVisitors: number;
188
+ /**
189
+ * Indicates whether the owner's name is shown.
190
+ */
191
+ showOwnerName: boolean;
192
+ /**
193
+ * The name of the room owner.
194
+ */
195
+ ownerName: string;
196
+ /**
197
+ * The unique identifier of the room owner.
198
+ */
199
+ ownerUniqueId: string;
200
+ /**
201
+ * The categories associated with the room.
202
+ */
203
+ categories: string[];
204
+ /**
205
+ * The URL of the room's thumbnail image.
206
+ */
207
+ thumbnailUrl: string;
208
+ /**
209
+ * The URL of the room's image.
210
+ */
211
+ imageUrl: string;
212
+ /**
213
+ * The rating of the room.
214
+ */
215
+ rating: number;
216
+ /**
217
+ * The unique identifier of the room.
218
+ */
219
+ uniqueId: string;
220
+ }
221
+
222
+ /**
223
+ * Represents a group associated with a Habbo user.
224
+ */
225
+ export interface HabboUserGroup {
226
+ /**
227
+ * Indicates whether the group is online.
228
+ */
229
+ online: boolean;
230
+ /**
231
+ * The unique identifier of the group.
232
+ */
233
+ id: string;
234
+ /**
235
+ * The name of the group.
236
+ */
237
+ name: string;
238
+ /**
239
+ * The description of the group.
240
+ */
241
+ description: string;
242
+ /**
243
+ * The type of the group.
244
+ */
245
+ type: HabboGroupType;
246
+ /**
247
+ * The unique identifier of the room associated with the group.
248
+ */
249
+ roomId: string;
250
+ /**
251
+ * The badge code of the group.
252
+ */
253
+ badgeCode: string;
254
+ /**
255
+ * The primary color of the group.
256
+ */
257
+ primaryColour: string;
258
+ /**
259
+ * The secondary color of the group.
260
+ */
261
+ secondaryColour: string;
262
+ /**
263
+ * Indicates whether the user is an admin of the group.
264
+ */
265
+ isAdmin: boolean;
266
+ }
267
+
268
+ /**
269
+ * Represents a badge owned by a Habbo user.
270
+ */
271
+ export interface HabboUserBadge {
272
+ /**
273
+ * The code of the badge.
274
+ */
275
+ code: string;
276
+ /**
277
+ * The name of the badge.
278
+ */
279
+ name: string;
280
+ /**
281
+ * The description of the badge.
282
+ */
283
+ description: string;
284
+ }
285
+
286
+ /**
287
+ * Represents a selected badge of a Habbo user.
288
+ */
289
+ export interface HabboUserSelectedBadge extends HabboUserBadge {
290
+ /**
291
+ * The index of the badge.
292
+ */
293
+ badgeIndex: number;
294
+ }
295
+
296
+ /**
297
+ * Represents a friend of a Habbo user.
298
+ */
299
+ export interface HabboUserFriend {
300
+ /**
301
+ * The unique identifier of the friend.
302
+ */
303
+ uniqueId: string;
304
+ /**
305
+ * The name of the friend.
306
+ */
307
+ name: string;
308
+ /**
309
+ * The figure string of the friend.
310
+ */
311
+ figureString: string;
312
+ /**
313
+ * The motto of the friend.
314
+ */
315
+ motto: string;
316
+ /**
317
+ * Indicates whether the friend is online.
318
+ */
319
+ online: boolean;
320
+ }
321
+
322
+ /**
323
+ * Represents the profile of a Habbo user.
324
+ */
325
+ export interface HabboUserProfile {
326
+ /**
327
+ * The unique identifier of the user.
328
+ */
329
+ uniqueId: string;
330
+ /**
331
+ * The name of the user.
332
+ */
333
+ name: string;
334
+ /**
335
+ * The figure string of the user.
336
+ */
337
+ figureString: string;
338
+ /**
339
+ * The motto of the user.
340
+ */
341
+ motto: string;
342
+ /**
343
+ * Indicates whether the user is online.
344
+ */
345
+ online: boolean;
346
+ /**
347
+ * The last access time of the user.
348
+ */
349
+ lastAccessTime: string;
350
+ /**
351
+ * The date when the user became a member.
352
+ */
353
+ memberSince: string;
354
+ /**
355
+ * Indicates whether the user's profile is visible.
356
+ */
357
+ profileVisible: boolean;
358
+ /**
359
+ * The current level of the user.
360
+ */
361
+ currentLevel: number;
362
+ /**
363
+ * The percentage of the current level completed by the user.
364
+ */
365
+ currentLevelCompletePercent: number;
366
+ /**
367
+ * The total experience points of the user.
368
+ */
369
+ totalExperience: number;
370
+ /**
371
+ * The number of star gems the user has.
372
+ */
373
+ starGemCount: number;
374
+ /**
375
+ * The badges selected by the user.
376
+ */
377
+ selectedBadges: HabboUserSelectedBadge[];
378
+ /**
379
+ * The groups the user is a member of.
380
+ */
381
+ groups: HabboUserGroup[];
382
+ /**
383
+ * The badges owned by the user.
384
+ */
385
+ badges: HabboUserBadge[];
386
+ /**
387
+ * The friends of the user.
388
+ */
389
+ friends: HabboUserFriend[];
390
+ /**
391
+ * The rooms owned by the user.
392
+ */
393
+ rooms: HabboUserRoom[];
394
+ }
395
+
396
+ /**
397
+ * Represents photos associated with a Habbo user.
398
+ */
399
+ export interface HabboUserPhotos {
400
+ /**
401
+ * The unique identifier of the room where the photo was taken.
402
+ */
403
+ room_id: number;
404
+ /**
405
+ * The unique identifier of the photo creator.
406
+ */
407
+ creator_id: number;
408
+ /**
409
+ * The name of the photo creator.
410
+ */
411
+ creator_name: string;
412
+ /**
413
+ * The time when the photo was taken.
414
+ */
415
+ time: number;
416
+ /**
417
+ * The version of the photo.
418
+ */
419
+ version: number;
420
+ /**
421
+ * The URL of the photo.
422
+ */
423
+ url: string;
424
+ /**
425
+ * The type of the photo.
426
+ */
427
+ type: string;
428
+ /**
429
+ * The unique identifier of the photo creator.
430
+ */
431
+ creator_uniqueId: string;
432
+ /**
433
+ * The tags associated with the photo.
434
+ */
435
+ tags: string[];
436
+ /**
437
+ * The URL of the photo preview.
438
+ */
439
+ previewUrl: string;
440
+ /**
441
+ * The unique identifier of the photo.
442
+ */
443
+ id: string;
444
+ /**
445
+ * The likes associated with the photo.
446
+ */
447
+ likes: string[];
448
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "outDir": "../dist",
6
+ "rootDir": ".",
7
+ "baseUrl": ".",
8
+ "resolvePackageJsonImports": true,
9
+ "module": "Node18",
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["."],
13
+ "exclude": ["./tsconfig.json"]
14
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["@sapphire/ts-config", "@sapphire/ts-config/extra-strict", "@sapphire/ts-config/verbatim"]
3
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "allowJs": true,
5
+ "checkJs": true
6
+ },
7
+ "include": ["src"]
8
+ }