sidechat.js 2.3.2 → 2.3.6
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/dist/classes/SidechatAPIClient.d.ts +41 -3
- package/dist/classes/SidechatAPIClient.d.ts.map +1 -1
- package/dist/classes/SidechatColorList.d.ts +25 -0
- package/dist/classes/SidechatColorList.d.ts.map +1 -0
- package/dist/index.cjs +250 -4
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +250 -5
- package/docs/sidechat.js/2.3.3/SidechatAPIClient.html +3 -0
- package/docs/sidechat.js/2.3.3/SidechatAPIError.html +3 -0
- package/docs/sidechat.js/2.3.3/classes_SidechatAPIClient.js.html +752 -0
- package/docs/sidechat.js/2.3.3/classes_SidechatAPIError.js.html +16 -0
- package/docs/sidechat.js/2.3.3/data/search.json +1 -0
- package/docs/sidechat.js/2.3.3/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/sidechat.js/2.3.3/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/sidechat.js/2.3.3/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/sidechat.js/2.3.3/global.html +3 -0
- package/docs/sidechat.js/2.3.3/index.html +4 -0
- package/docs/sidechat.js/2.3.3/scripts/core.js +702 -0
- package/docs/sidechat.js/2.3.3/scripts/core.min.js +23 -0
- package/docs/sidechat.js/2.3.3/scripts/resize.js +90 -0
- package/docs/sidechat.js/2.3.3/scripts/search.js +265 -0
- package/docs/sidechat.js/2.3.3/scripts/search.min.js +6 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/fuse.js +9 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/hljs-original.js +5171 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/hljs.js +1 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/popper.js +5 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/tippy.js +1 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/tocbot.js +672 -0
- package/docs/sidechat.js/2.3.3/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-base.css +975 -0
- package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-dark.css +407 -0
- package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme-light.css +388 -0
- package/docs/sidechat.js/2.3.3/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/sidechat.js/2.3.3/tutorial-Authentication.html +14 -0
- package/docs/sidechat.js/2.3.3/tutorial-Email Registration.html +6 -0
- package/docs/sidechat.js/2.3.3/types_SidechatTypes.js.html +134 -0
- package/docs/sidechat.js/2.3.6/SidechatAPIClient.html +3 -0
- package/docs/sidechat.js/2.3.6/SidechatAPIError.html +3 -0
- package/docs/sidechat.js/2.3.6/classes_SidechatAPIClient.js.html +919 -0
- package/docs/sidechat.js/2.3.6/classes_SidechatAPIError.js.html +16 -0
- package/docs/sidechat.js/2.3.6/classes_SidechatColorList.js.html +80 -0
- package/docs/sidechat.js/2.3.6/data/search.json +1 -0
- package/docs/sidechat.js/2.3.6/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/sidechat.js/2.3.6/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/sidechat.js/2.3.6/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/sidechat.js/2.3.6/global.html +3 -0
- package/docs/sidechat.js/2.3.6/index.html +4 -0
- package/docs/sidechat.js/2.3.6/scripts/core.js +702 -0
- package/docs/sidechat.js/2.3.6/scripts/core.min.js +23 -0
- package/docs/sidechat.js/2.3.6/scripts/resize.js +90 -0
- package/docs/sidechat.js/2.3.6/scripts/search.js +265 -0
- package/docs/sidechat.js/2.3.6/scripts/search.min.js +6 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/fuse.js +9 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/hljs-original.js +5171 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/hljs.js +1 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/popper.js +5 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/tippy.js +1 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/tocbot.js +672 -0
- package/docs/sidechat.js/2.3.6/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme-base.css +975 -0
- package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme-dark.css +407 -0
- package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme-light.css +388 -0
- package/docs/sidechat.js/2.3.6/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/sidechat.js/2.3.6/tutorial-Authentication.html +14 -0
- package/docs/sidechat.js/2.3.6/tutorial-Email Registration.html +6 -0
- package/docs/sidechat.js/2.3.6/types_SidechatTypes.js.html +134 -0
- package/jsdoc.json +2 -1
- package/package.json +1 -1
- package/src/classes/SidechatAPIClient.js +173 -4
- package/src/classes/SidechatColorList.js +77 -0
- package/src/index.js +2 -1
- package/src/tests/colorTest.js +1 -0
|
@@ -114,6 +114,14 @@ declare class SidechatAPIClient {
|
|
|
114
114
|
* @returns {SidechatPostOrComment} post object
|
|
115
115
|
*/
|
|
116
116
|
getPost: (postID: string, includeDeleted?: boolean) => SidechatPostOrComment;
|
|
117
|
+
/**
|
|
118
|
+
* Fetches the posts or comments that the user has created
|
|
119
|
+
* @method
|
|
120
|
+
* @since 2.3.5
|
|
121
|
+
* @param {"posts"|"comments"} contentType - type of user content to fetch
|
|
122
|
+
* @returns {SidechatPostOrComment[]} post object
|
|
123
|
+
*/
|
|
124
|
+
getUserContent: (contentType: "posts" | "comments") => SidechatPostOrComment[];
|
|
117
125
|
/**
|
|
118
126
|
* Get all the commments on a post
|
|
119
127
|
* @method
|
|
@@ -126,9 +134,10 @@ declare class SidechatAPIClient {
|
|
|
126
134
|
* Gets groups to be displayed on the "Explore Groups" page
|
|
127
135
|
* @method
|
|
128
136
|
* @since 2.0.0-alpha.0
|
|
137
|
+
* @param {Boolean} onePage - whether or not results should be returned as a single page
|
|
129
138
|
* @returns {SidechatGroup[]}
|
|
130
139
|
*/
|
|
131
|
-
getAvailableGroups: () => SidechatGroup[];
|
|
140
|
+
getAvailableGroups: (onePage?: boolean) => SidechatGroup[];
|
|
132
141
|
/**
|
|
133
142
|
* Retrieves the entire accessible asset library. Be warned that as of the time of this documentation, it's a 1.5MB JSON download and this request is very expensive.
|
|
134
143
|
* @method
|
|
@@ -173,9 +182,10 @@ declare class SidechatAPIClient {
|
|
|
173
182
|
* @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach.
|
|
174
183
|
* @param {Boolean} [disableDMs] - prevent direct messages from being sent to post's author
|
|
175
184
|
* @param {Boolean} [disableComments] - whether or not comments should be disabled on post
|
|
185
|
+
* @param {Boolean} [anonymous] - whether or not to hide user's name and icon on post
|
|
176
186
|
* @returns {SidechatPostOrComment} the created post
|
|
177
187
|
*/
|
|
178
|
-
createPost: (text: string, groupID: string, assetList?: SidechatSimpleAsset[], disableDMs?: boolean, disableComments?: boolean) => SidechatPostOrComment;
|
|
188
|
+
createPost: (text: string, groupID: string, assetList?: SidechatSimpleAsset[], disableDMs?: boolean, disableComments?: boolean, anonymous?: boolean) => SidechatPostOrComment;
|
|
179
189
|
/**
|
|
180
190
|
* Deletes a post or comment that the user created
|
|
181
191
|
* @method
|
|
@@ -187,12 +197,28 @@ declare class SidechatAPIClient {
|
|
|
187
197
|
* Sets the conversation icon of the current user
|
|
188
198
|
* @method
|
|
189
199
|
* @since 2.2.1
|
|
190
|
-
* @param {String} userID - alphanumeric ID of
|
|
200
|
+
* @param {String} userID - alphanumeric ID of user
|
|
191
201
|
* @param {String} emoji - emoji to set as icon
|
|
192
202
|
* @param {String} primaryColor - hex string (including #) of primary color
|
|
193
203
|
* @param {String} secondaryColor - hex string (including #) of secondary color
|
|
194
204
|
*/
|
|
195
205
|
setUserIcon: (userID: string, emoji: string, primaryColor: string, secondaryColor: string) => Promise<any>;
|
|
206
|
+
/**
|
|
207
|
+
* Checks if user can set their username to a string
|
|
208
|
+
* @method
|
|
209
|
+
* @since 2.3.6
|
|
210
|
+
* @param {String} username - string to check
|
|
211
|
+
* @returns {Boolean} whether or not username is valid and unused
|
|
212
|
+
*/
|
|
213
|
+
checkUsername: (username: string) => boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Changes the username of the current user
|
|
216
|
+
* @method
|
|
217
|
+
* @since 2.3.6
|
|
218
|
+
* @param {String} userID - alphanumeric ID of user
|
|
219
|
+
* @param {String} username - new username to set
|
|
220
|
+
*/
|
|
221
|
+
setUsername: (userID: string, username: string) => Promise<any>;
|
|
196
222
|
/**
|
|
197
223
|
* Marks an activity item as read
|
|
198
224
|
* @method
|
|
@@ -200,5 +226,17 @@ declare class SidechatAPIClient {
|
|
|
200
226
|
* @param {String} activityID - alphanumeric ID of activity object
|
|
201
227
|
*/
|
|
202
228
|
readActivity: (activityID: string) => Promise<any>;
|
|
229
|
+
/**
|
|
230
|
+
* Retrieves joinable group chats
|
|
231
|
+
* @method
|
|
232
|
+
* @since 2.3.5
|
|
233
|
+
*/
|
|
234
|
+
getGroupChats: () => Promise<any>;
|
|
235
|
+
/**
|
|
236
|
+
* Joins a group chat
|
|
237
|
+
* @method
|
|
238
|
+
* @since 2.3.5
|
|
239
|
+
*/
|
|
240
|
+
joinGroupChat: (groupChatID: any, displayName: any, emoji: any, primaryColor: any, secondaryColor: any) => Promise<any>;
|
|
203
241
|
}
|
|
204
242
|
//# sourceMappingURL=SidechatAPIClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IAmBE;;;OAGG;IACH,uCAIC;IA1BD;;;SAGK;IACL,6BAAU;IACV;;;;;OAKG;IACH,oBAKE;IAYF;;;;OAIG;IACH,6CAEE;IAEF;;;;;OAKG;IACH,mDAgBE;IAEF;;;;;;OAMG;IACH,mEAsBE;IAEF;;;;;;OAMG;IACH,8DAyBE;IAEF;;;;;;OAMG;IACH,+CA2BE;IAEF;;;;OAIG;IACH,2CAyBE;IAEF;;;;;OAKG;IACH,6CA2BE;IAEF;;;;;;OAMG;IACH,oDAGE;IAEF;;;;;OAKG;IACH,+CAqBE;IAEF;;;;;;;;OAQG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,2DA2B7B;IAEF;;;;;;OAMG;IACH,sEAsBE;IAEF;;;;;;;OAOG;IACH,6EAqBE;IAEF;;;;;;OAMG;IACH,qCAFa,uBAAuB,CAqElC;IAEF
|
|
1
|
+
{"version":3,"file":"SidechatAPIClient.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatAPIClient.js"],"names":[],"mappings":";AAGA;;;;GAIG;AACH;IAmBE;;;OAGG;IACH,uCAIC;IA1BD;;;SAGK;IACL,6BAAU;IACV;;;;;OAKG;IACH,oBAKE;IAYF;;;;OAIG;IACH,6CAEE;IAEF;;;;;OAKG;IACH,mDAgBE;IAEF;;;;;;OAMG;IACH,mEAsBE;IAEF;;;;;;OAMG;IACH,8DAyBE;IAEF;;;;;;OAMG;IACH,+CA2BE;IAEF;;;;OAIG;IACH,2CAyBE;IAEF;;;;;OAKG;IACH,6CA2BE;IAEF;;;;;;OAMG;IACH,oDAGE;IAEF;;;;;OAKG;IACH,+CAqBE;IAEF;;;;;;;;OAQG;IACH,4CAJW,KAAK,GAAC,QAAQ,GAAC,KAAK,2DA2B7B;IAEF;;;;;;OAMG;IACH,sEAsBE;IAEF;;;;;;;OAOG;IACH,6EAqBE;IAEF;;;;;;OAMG;IACH,8BAHW,OAAO,GAAC,UAAU,KAChB,uBAAuB,CA4BlC;IAEF;;;;;;OAMG;IACH,qCAFa,uBAAuB,CAqElC;IAEF;;;;;;OAMG;IACH,2CAFa,eAAe,CAqB1B;IAEF;;;;;OAKG;IACH,uBAFa,sBAAsB,CAoBjC;IAEF;;;;;OAKG;IACH,0CAkBE;IAEF;;;;;;OAMG;IACH,sDAkBE;IAEF;;;;;;;;;;;OAWG;IACH,0GAJW,qBAAqB,iDAsC9B;IAEF;;;;;;;;;;;OAWG;IACH,wDANW,qBAAqB,iGAyC9B;IAEF;;;;;OAKG;IACH,+DAqBE;IAEF;;;;;;;;OAQG;IACH,2GA2BE;IAEF;;;;;;OAMG;IACH,6CAwBE;IAEF;;;;;;OAMG;IACH,gEAqBE;IAEF;;;;;OAKG;IACH,mDAqBE;IAEF;;;;OAIG;IACH,kCAkBE;IAEF;;;;OAIG;IACH,wHAiCE;CACH"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export default SidechatColorList;
|
|
2
|
+
export type SidechatColor = {
|
|
3
|
+
/**
|
|
4
|
+
* - hex code of primary color
|
|
5
|
+
*/
|
|
6
|
+
primary: string;
|
|
7
|
+
/**
|
|
8
|
+
* - hex code of secondary color
|
|
9
|
+
*/
|
|
10
|
+
secondary: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @typedef SidechatColor
|
|
14
|
+
* @prop {String} primary - hex code of primary color
|
|
15
|
+
* @prop {String} secondary - hex code of secondary color
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* List of colors compatible with user conversation icons
|
|
19
|
+
* @constant
|
|
20
|
+
* @type {{ colors: SidechatColor[] }}
|
|
21
|
+
*/
|
|
22
|
+
declare const SidechatColorList: {
|
|
23
|
+
colors: SidechatColor[];
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=SidechatColorList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SidechatColorList.d.ts","sourceRoot":"","sources":["../../src/classes/SidechatColorList.js"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;GAIG;AAEH;;;;GAIG;AACH,iCAFU;IAAE,MAAM,EAAE,aAAa,EAAE,CAAA;CAAE,CAiEnC"}
|
package/dist/index.cjs
CHANGED
|
@@ -34,7 +34,7 @@ class SidechatAPIClient {
|
|
|
34
34
|
defaultHeaders = {
|
|
35
35
|
Accept: "application/json",
|
|
36
36
|
"Content-Type": "application/json",
|
|
37
|
-
"App-Version": "
|
|
37
|
+
"App-Version": "4.2.0",
|
|
38
38
|
Dnt: 1,
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -386,6 +386,41 @@ class SidechatAPIClient {
|
|
|
386
386
|
}
|
|
387
387
|
};
|
|
388
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Fetches the posts or comments that the user has created
|
|
391
|
+
* @method
|
|
392
|
+
* @since 2.3.5
|
|
393
|
+
* @param {"posts"|"comments"} contentType - type of user content to fetch
|
|
394
|
+
* @returns {SidechatPostOrComment[]} post object
|
|
395
|
+
*/
|
|
396
|
+
getUserContent = async (contentType) => {
|
|
397
|
+
if (!this.userToken) {
|
|
398
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
399
|
+
}
|
|
400
|
+
if (contentType == "posts") {
|
|
401
|
+
contentType = "my_posts";
|
|
402
|
+
} else if (contentType == "comments") {
|
|
403
|
+
contentType = "my_comments";
|
|
404
|
+
}
|
|
405
|
+
try {
|
|
406
|
+
const res = await fetch(
|
|
407
|
+
`https://api.sidechat.lol/v1/posts&type=${contentType}`,
|
|
408
|
+
{
|
|
409
|
+
method: "GET",
|
|
410
|
+
headers: {
|
|
411
|
+
...this.defaultHeaders,
|
|
412
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
413
|
+
},
|
|
414
|
+
}
|
|
415
|
+
);
|
|
416
|
+
const json = await res.json();
|
|
417
|
+
return json.posts;
|
|
418
|
+
} catch (err) {
|
|
419
|
+
console.error(err);
|
|
420
|
+
throw new SidechatAPIError(`Failed to get content from user.`);
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
|
|
389
424
|
/**
|
|
390
425
|
* Get all the commments on a post
|
|
391
426
|
* @method
|
|
@@ -466,9 +501,10 @@ class SidechatAPIClient {
|
|
|
466
501
|
* Gets groups to be displayed on the "Explore Groups" page
|
|
467
502
|
* @method
|
|
468
503
|
* @since 2.0.0-alpha.0
|
|
504
|
+
* @param {Boolean} onePage - whether or not results should be returned as a single page
|
|
469
505
|
* @returns {SidechatGroup[]}
|
|
470
506
|
*/
|
|
471
|
-
getAvailableGroups = async () => {
|
|
507
|
+
getAvailableGroups = async (onePage = true) => {
|
|
472
508
|
if (!this.userToken) {
|
|
473
509
|
throw new SidechatAPIError("User is not authenticated.");
|
|
474
510
|
}
|
|
@@ -477,6 +513,7 @@ class SidechatAPIClient {
|
|
|
477
513
|
method: "GET",
|
|
478
514
|
headers: {
|
|
479
515
|
...this.defaultHeaders,
|
|
516
|
+
"App-Version": onePage ? "0" : this.defaultHeaders["App-Version"],
|
|
480
517
|
Authorization: `Bearer ${this.userToken}`,
|
|
481
518
|
},
|
|
482
519
|
});
|
|
@@ -624,6 +661,7 @@ class SidechatAPIClient {
|
|
|
624
661
|
* @param {SidechatSimpleAsset[]} [assetList] - list of assets to attach.
|
|
625
662
|
* @param {Boolean} [disableDMs] - prevent direct messages from being sent to post's author
|
|
626
663
|
* @param {Boolean} [disableComments] - whether or not comments should be disabled on post
|
|
664
|
+
* @param {Boolean} [anonymous] - whether or not to hide user's name and icon on post
|
|
627
665
|
* @returns {SidechatPostOrComment} the created post
|
|
628
666
|
*/
|
|
629
667
|
createPost = async (
|
|
@@ -631,7 +669,8 @@ class SidechatAPIClient {
|
|
|
631
669
|
groupID,
|
|
632
670
|
assetList = [],
|
|
633
671
|
disableDMs = false,
|
|
634
|
-
disableComments = false
|
|
672
|
+
disableComments = false,
|
|
673
|
+
anonymous = false
|
|
635
674
|
) => {
|
|
636
675
|
if (!this.userToken) {
|
|
637
676
|
throw new SidechatAPIError("User is not authenticated.");
|
|
@@ -651,6 +690,7 @@ class SidechatAPIClient {
|
|
|
651
690
|
attachments: [],
|
|
652
691
|
dms_disabled: disableDMs,
|
|
653
692
|
comments_disabled: disableComments,
|
|
693
|
+
using_identity: !anonymous,
|
|
654
694
|
}),
|
|
655
695
|
});
|
|
656
696
|
const json = await res.json();
|
|
@@ -694,7 +734,7 @@ class SidechatAPIClient {
|
|
|
694
734
|
* Sets the conversation icon of the current user
|
|
695
735
|
* @method
|
|
696
736
|
* @since 2.2.1
|
|
697
|
-
* @param {String} userID - alphanumeric ID of
|
|
737
|
+
* @param {String} userID - alphanumeric ID of user
|
|
698
738
|
* @param {String} emoji - emoji to set as icon
|
|
699
739
|
* @param {String} primaryColor - hex string (including #) of primary color
|
|
700
740
|
* @param {String} secondaryColor - hex string (including #) of secondary color
|
|
@@ -708,6 +748,7 @@ class SidechatAPIClient {
|
|
|
708
748
|
method: "PATCH",
|
|
709
749
|
headers: {
|
|
710
750
|
...this.defaultHeaders,
|
|
751
|
+
"App-Version": "0",
|
|
711
752
|
Authorization: `Bearer ${this.userToken}`,
|
|
712
753
|
},
|
|
713
754
|
body: JSON.stringify({
|
|
@@ -727,6 +768,69 @@ class SidechatAPIClient {
|
|
|
727
768
|
}
|
|
728
769
|
};
|
|
729
770
|
|
|
771
|
+
/**
|
|
772
|
+
* Checks if user can set their username to a string
|
|
773
|
+
* @method
|
|
774
|
+
* @since 2.3.6
|
|
775
|
+
* @param {String} username - string to check
|
|
776
|
+
* @returns {Boolean} whether or not username is valid and unused
|
|
777
|
+
*/
|
|
778
|
+
checkUsername = async (username) => {
|
|
779
|
+
if (!this.userToken) {
|
|
780
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
781
|
+
}
|
|
782
|
+
try {
|
|
783
|
+
const res = await fetch(
|
|
784
|
+
`https://api.sidechat.lol/v1/users/username?username=${username}`,
|
|
785
|
+
{
|
|
786
|
+
method: "GET",
|
|
787
|
+
headers: {
|
|
788
|
+
...this.defaultHeaders,
|
|
789
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
790
|
+
},
|
|
791
|
+
}
|
|
792
|
+
);
|
|
793
|
+
if (res?.status == 200 || res?.status == 204) {
|
|
794
|
+
return true;
|
|
795
|
+
} else {
|
|
796
|
+
return false;
|
|
797
|
+
}
|
|
798
|
+
} catch (err) {
|
|
799
|
+
console.error(err);
|
|
800
|
+
throw new SidechatAPIError(`Failed to check username.`);
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Changes the username of the current user
|
|
806
|
+
* @method
|
|
807
|
+
* @since 2.3.6
|
|
808
|
+
* @param {String} userID - alphanumeric ID of user
|
|
809
|
+
* @param {String} username - new username to set
|
|
810
|
+
*/
|
|
811
|
+
setUsername = async (userID, username) => {
|
|
812
|
+
if (!this.userToken) {
|
|
813
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
814
|
+
}
|
|
815
|
+
try {
|
|
816
|
+
const res = await fetch(`https://api.sidechat.lol/v1/users/${userID}`, {
|
|
817
|
+
method: "PATCH",
|
|
818
|
+
headers: {
|
|
819
|
+
...this.defaultHeaders,
|
|
820
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
821
|
+
},
|
|
822
|
+
body: JSON.stringify({
|
|
823
|
+
username: username,
|
|
824
|
+
}),
|
|
825
|
+
});
|
|
826
|
+
const json = await res.json();
|
|
827
|
+
return await json.user;
|
|
828
|
+
} catch (err) {
|
|
829
|
+
console.error(err);
|
|
830
|
+
throw new SidechatAPIError(`Failed to set icon.`);
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
|
|
730
834
|
/**
|
|
731
835
|
* Marks an activity item as read
|
|
732
836
|
* @method
|
|
@@ -755,7 +859,149 @@ class SidechatAPIClient {
|
|
|
755
859
|
throw new SidechatAPIError(`Failed to mark activity as read.`);
|
|
756
860
|
}
|
|
757
861
|
};
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Retrieves joinable group chats
|
|
865
|
+
* @method
|
|
866
|
+
* @since 2.3.5
|
|
867
|
+
*/
|
|
868
|
+
getGroupChats = async () => {
|
|
869
|
+
if (!this.userToken) {
|
|
870
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
871
|
+
}
|
|
872
|
+
try {
|
|
873
|
+
const res = await fetch(`https://api.sidechat.lol/v1/chats/explore`, {
|
|
874
|
+
method: "GET",
|
|
875
|
+
headers: {
|
|
876
|
+
...this.defaultHeaders,
|
|
877
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
878
|
+
},
|
|
879
|
+
});
|
|
880
|
+
const json = await res.json();
|
|
881
|
+
return await json.chats;
|
|
882
|
+
} catch (err) {
|
|
883
|
+
console.error(err);
|
|
884
|
+
throw new SidechatAPIError(`Failed to get groupchats.`);
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Joins a group chat
|
|
890
|
+
* @method
|
|
891
|
+
* @since 2.3.5
|
|
892
|
+
*/
|
|
893
|
+
joinGroupChat = async (
|
|
894
|
+
groupChatID,
|
|
895
|
+
displayName,
|
|
896
|
+
emoji,
|
|
897
|
+
primaryColor,
|
|
898
|
+
secondaryColor
|
|
899
|
+
) => {
|
|
900
|
+
if (!this.userToken) {
|
|
901
|
+
throw new SidechatAPIError("User is not authenticated.");
|
|
902
|
+
}
|
|
903
|
+
try {
|
|
904
|
+
const res = await fetch(`https://api.sidechat.lol/v1/chats/groups/join`, {
|
|
905
|
+
method: "GET",
|
|
906
|
+
headers: {
|
|
907
|
+
...this.defaultHeaders,
|
|
908
|
+
Authorization: `Bearer ${this.userToken}`,
|
|
909
|
+
},
|
|
910
|
+
body: JSON.stringify({
|
|
911
|
+
chat_id: groupChatID,
|
|
912
|
+
identity: {
|
|
913
|
+
display_name: displayName,
|
|
914
|
+
emoji: emoji,
|
|
915
|
+
secondary_color: secondaryColor,
|
|
916
|
+
color: primaryColor,
|
|
917
|
+
},
|
|
918
|
+
}),
|
|
919
|
+
});
|
|
920
|
+
const json = await res.json();
|
|
921
|
+
return await json;
|
|
922
|
+
} catch (err) {
|
|
923
|
+
console.error(err);
|
|
924
|
+
throw new SidechatAPIError(`Failed to join groupchat.`);
|
|
925
|
+
}
|
|
926
|
+
};
|
|
758
927
|
}
|
|
759
928
|
|
|
929
|
+
/**
|
|
930
|
+
* @typedef SidechatColor
|
|
931
|
+
* @prop {String} primary - hex code of primary color
|
|
932
|
+
* @prop {String} secondary - hex code of secondary color
|
|
933
|
+
*/
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* List of colors compatible with user conversation icons
|
|
937
|
+
* @constant
|
|
938
|
+
* @type {{ colors: SidechatColor[] }}
|
|
939
|
+
*/
|
|
940
|
+
const SidechatColorList = {
|
|
941
|
+
colors: [
|
|
942
|
+
{
|
|
943
|
+
primary: "#74DEEE",
|
|
944
|
+
secondary: "#239EAB",
|
|
945
|
+
},
|
|
946
|
+
{
|
|
947
|
+
primary: "#15FF46",
|
|
948
|
+
secondary: "#3FC0FF",
|
|
949
|
+
},
|
|
950
|
+
{
|
|
951
|
+
primary: "#D9FB8A",
|
|
952
|
+
secondary: "#B1FD00",
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
primary: "#FC40FF",
|
|
956
|
+
secondary: "#0DD5B2",
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
primary: "#3E973C",
|
|
960
|
+
secondary: "#0F430E",
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
primary: "#FFD305",
|
|
964
|
+
secondary: "#F4B320",
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
primary: "#8483FF",
|
|
968
|
+
secondary: "#5857FF",
|
|
969
|
+
},
|
|
970
|
+
{
|
|
971
|
+
primary: "#FA81FF",
|
|
972
|
+
secondary: "#722DFF",
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
primary: "#00CBFE",
|
|
976
|
+
secondary: "#0D13D5",
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
primary: "#FF7B51",
|
|
980
|
+
secondary: "#B2431F",
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
primary: "#FF47CC",
|
|
984
|
+
secondary: "#69004C",
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
primary: "#00EE6E",
|
|
988
|
+
secondary: "#0C75E6",
|
|
989
|
+
},
|
|
990
|
+
{
|
|
991
|
+
primary: "#FF1885",
|
|
992
|
+
secondary: "#FA81FF",
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
primary: "#D8DC44",
|
|
996
|
+
secondary: "#228B3F",
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
primary: "#0968E5",
|
|
1000
|
+
secondary: "#091970",
|
|
1001
|
+
},
|
|
1002
|
+
],
|
|
1003
|
+
};
|
|
1004
|
+
|
|
760
1005
|
exports.SidechatAPIClient = SidechatAPIClient;
|
|
761
1006
|
exports.SidechatAPIError = SidechatAPIError;
|
|
1007
|
+
exports.SidechatColorList = SidechatColorList;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SidechatAPIClient from "./classes/SidechatAPIClient.js";
|
|
2
2
|
import SidechatAPIError from "./classes/SidechatAPIError.js";
|
|
3
|
-
|
|
3
|
+
import SidechatColorList from "./classes/SidechatColorList.js";
|
|
4
|
+
export { SidechatAPIClient, SidechatAPIError, SidechatColorList };
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import SidechatAPIClient from "./classes/SidechatAPIClient.js";
|
|
2
2
|
import SidechatAPIError from "./classes/SidechatAPIError.js";
|
|
3
|
-
|
|
3
|
+
import SidechatColorList from "./classes/SidechatColorList.js";
|
|
4
|
+
export { SidechatAPIClient, SidechatAPIError, SidechatColorList };
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"8BAC8B,gCAAgC;6BACjC,+BAA+B"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"8BAC8B,gCAAgC;6BACjC,+BAA+B;8BAC9B,gCAAgC"}
|