diff --git a/src/ScratchSession.ts b/src/ScratchSession.ts index cea4cef..e0039b1 100644 --- a/src/ScratchSession.ts +++ b/src/ScratchSession.ts @@ -204,6 +204,11 @@ class ScratchSession { }[]; } + /** + * Get messages + * @param limit The limit of messages to get + * @param offset The offset of messages + */ async getMessages(limit: number = 40, offset: number = 0) { const request = await fetch(`https://api.scratch.mit.edu/users/${this.username}/messages?limit=${limit}&offset=${offset}`, { headers: { @@ -215,7 +220,11 @@ class ScratchSession { if(!request.ok) throw Error(`Request failed with status ${request.status}`); return (await request.json()) as Message[]; } - + + /** + * Get the message count + * @returns The number of messages + */ async getMessageCount() { const request = await fetch(`https://api.scratch.mit.edu/users/${this.username}/messages/count`); if(!request.ok) throw Error(`Request failed with status ${request.status}`); diff --git a/src/classes/Project.ts b/src/classes/Project.ts index 880879e..1709fc5 100644 --- a/src/classes/Project.ts +++ b/src/classes/Project.ts @@ -289,6 +289,10 @@ class Project { } } + /** + * Set the thumbnail of the project + * @param buffer The buffer of the thumbnail image file + */ async setThumbnail(buffer: Buffer) { const request = await fetch( `https://scratch.mit.edu/internalapi/project/thumbnail/${this.id}/set/`, diff --git a/src/classes/Studio.ts b/src/classes/Studio.ts index f2b3014..0349815 100644 --- a/src/classes/Studio.ts +++ b/src/classes/Studio.ts @@ -51,6 +51,9 @@ class Studio { this.session = session; } + /** + * Get the API data of the studio + */ async getAPIData() { const response = await fetch( `https://api.scratch.mit.edu/studios/${this.id}/`, @@ -63,6 +66,9 @@ class Studio { return (await response.json()) as StudioAPIResponse; } + /** + * Follow the studio + */ async follow() { const request = await fetch( `https://scratch.mit.edu/site-api/users/bookmarkers/${this.id}/add/?usernames=${this.session.sessionJSON.user.username}`, @@ -84,6 +90,9 @@ class Studio { throw Error(`Request failed with status ${request.status}`); } + /** + * Unfollow the studio + */ async unfollow() { const request = await fetch( `https://scratch.mit.edu/site-api/users/bookmarkers/${this.id}/remove/?usernames=${this.session.sessionJSON.user.username}`,