Skip to content

Commit

Permalink
move from session to profile
Browse files Browse the repository at this point in the history
  • Loading branch information
webdev03 committed Oct 5, 2023
1 parent 7c7da7a commit 50bc5df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 0 additions & 10 deletions src/ScratchSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,6 @@ 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}`);
return Number((await request.json()).count);
}

/**
* Logs out of Scratch.
Expand Down
10 changes: 10 additions & 0 deletions src/classes/Profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ class Profile {
}
return (await scratchUserFetch.json()) as UserAPIResponse;
}

/**
* Get the message count
* @returns The number of messages
*/
async getMessageCount() {
const request = await fetch(`https://api.scratch.mit.edu/users/${this.user}/messages/count`);
if(!request.ok) throw Error(`Request failed with status ${request.status}`);
return Number((await request.json()).count);
}

/**
* Gets comments on the user's profile.
Expand Down

0 comments on commit 50bc5df

Please sign in to comment.