Skip to content

Commit d50454a

Browse files
committed
Add modifying user bio
1 parent 2c522e8 commit d50454a

3 files changed

Lines changed: 33 additions & 12 deletions

File tree

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sidechat.js",
3-
"version": "2.5.5",
3+
"version": "2.5.6",
44
"description": "A reverse-engineered API wrapper for Sidechat",
55
"type": "module",
66
"source": "./src/index.js",
@@ -49,6 +49,6 @@
4949
"prompt-sync": "^4.2.0",
5050
"rollup": "^2.79.2",
5151
"rollup-plugin-copy": "^3.5.0",
52-
"typescript": "^5.7.2"
52+
"typescript": "^5.7.3"
5353
}
5454
}

src/classes/SidechatAPIClient.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -873,10 +873,7 @@ class SidechatAPIClient {
873873
uri: uri,
874874
});
875875

876-
const urlReq = await this.sendRequest(
877-
`/v1/assets/upload_url?content_type=${imageType}`,
878-
"GET"
879-
);
876+
const urlReq = await this.sendRequest(`/v1/assets/upload_url?content_type=${imageType}`);
880877
const urlJson = await urlReq.json();
881878

882879
try {
@@ -937,6 +934,30 @@ class SidechatAPIClient {
937934
}
938935
};
939936

937+
setUserBio = async (userID, bio) => {
938+
if (!this.userToken) {
939+
throw new SidechatAPIError("User is not authenticated.");
940+
}
941+
try {
942+
const res = await fetch(`${this.apiRoot}/v1/users/${userID}`, {
943+
method: "PATCH",
944+
headers: {
945+
...this.defaultHeaders,
946+
"App-Version": "5.4.22",
947+
Authorization: `Bearer ${this.userToken}`,
948+
},
949+
body: JSON.stringify({
950+
bio: bio
951+
}),
952+
});
953+
const json = await res.json();
954+
return await json;
955+
} catch (err) {
956+
console.error(err);
957+
throw new SidechatAPIError(`Failed to set bio.`);
958+
}
959+
};
960+
940961
/**
941962
* Checks if user can set their username to a string
942963
* @method

0 commit comments

Comments
 (0)