Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/reddit/src/models/User.ts
Comment thread
stephenoid marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ export class User {
#commentKarma: number;
#nsfw: boolean;
#isAdmin: boolean;
#isModerator: boolean;
Comment thread
stephenoid marked this conversation as resolved.
#isGold: boolean;
#modPermissionsBySubreddit: Map<string, ModeratorPermission[]> = new Map();
// R2 bug: user.url is a permalink path
#url: string;
Expand All @@ -242,8 +244,10 @@ export class User {
// UserDataByAccountIds returns the ID without the t2_ prefix
this.#id = T2(isT2(data.id) ? data.id : `t2_${data.id}`);
this.#username = data.name;
this.#nsfw = data.over18 ?? false;
this.#nsfw = data.subreddit?.over18 ?? false;
this.#isAdmin = data.isEmployee ?? false;
this.#isModerator = data.IsMod ?? false;
Comment thread
stephenoid marked this conversation as resolved.
this.#isGold = data.isGold ?? false;

const createdAt = new Date(0);
createdAt.setUTCSeconds(data.createdUtc);
Expand Down Expand Up @@ -315,6 +319,16 @@ export class User {
return this.#isAdmin;
}

/** Whether the user is a moderator of any subreddit. */
get isModerator(): boolean {
return this.#isModerator;
}

/** Whether the user has Reddit Premium. */
get hasRedditPremium(): boolean {
return this.#isGold;
}

/**
* The permissions the user has on the subreddit.
*/
Expand Down