Skip to main content
Version: 0.11

User

@devvit/public-api v0.11.19-dev


Class: User

A class representing a user.

Accessors

commentKarma

Get Signature

get commentKarma(): number

The amount of comment karma the user has.

Returns

number


createdAt

Get Signature

get createdAt(): Date

The date the user was created.

Returns

Date


hasVerifiedEmail

Get Signature

get hasVerifiedEmail(): boolean

Indicates whether or not the user has verified their email address.

Returns

boolean


id

Get Signature

get id(): `t2_${string}`

The ID (starting with t2_) of the user to retrieve.

Example
't2_1w72';
Returns

`t2_${string}`


isAdmin

Get Signature

get isAdmin(): boolean

Whether the user is admin.

Returns

boolean


linkKarma

Get Signature

get linkKarma(): number

The amount of link karma the user has.

Returns

number


modPermissions

Get Signature

get modPermissions(): Map<string, ModeratorPermission[]>

The permissions the user has on the subreddit.

Returns

Map<string, ModeratorPermission[]>


nsfw

Get Signature

get nsfw(): boolean

Whether the user's profile is marked as NSFW (Not Safe For Work).

Returns

boolean


Get Signature

get permalink(): string

Returns a permalink path relative to https://www.reddit.com

Returns

string


url

Get Signature

get url(): string

Returns the HTTP URL for the user

Returns

string


username

Get Signature

get username(): string

The username of the user omitting the u/.

Example
'spez';
Returns

string

Methods

getComments()

getComments(options): Listing<Comment>

Get the user's comments.

Parameters

options

Omit<GetCommentsByUserOptions, "username">

Options for the request

Returns

Listing<Comment>

A Listing of Comment objects.


getModPermissionsForSubreddit()

getModPermissionsForSubreddit(subredditName): Promise<ModeratorPermission[]>

Get the mod permissions the user has on the subreddit if they are a moderator.

Parameters

subredditName

string

name of the subreddit

Returns

Promise<ModeratorPermission[]>

the moderator permissions the user has on the subreddit


getPosts()

getPosts(options): Listing<Post>

Get the user's posts.

Parameters

options

Omit<GetPostsByUserOptions, "username">

Options for the request

Returns

Listing<Post>

A Listing of Post objects.


getSnoovatarUrl()

getSnoovatarUrl(): Promise<undefined | string>

Returns

Promise<undefined | string>


getSocialLinks(): Promise<UserSocialLink[]>

Gets social links of the user

Returns

Promise<UserSocialLink[]>

A Promise that resolves an Array of UserSocialLink objects

Example

const socialLinks = await user.getSocialLinks();

getUserFlairBySubreddit()

getUserFlairBySubreddit(subreddit): Promise<undefined | UserFlair>

Retrieve the user's flair for the subreddit.

Parameters

subreddit

string

The name of the subreddit associated with the user's flair.

Returns

Promise<undefined | UserFlair>

Example

const username = 'badapple';
const subredditName = 'mysubreddit';
const user = await reddit.getUserByUsername(username);
const userFlair = await user.getUserFlairBySubreddit(subredditName);

toJSON()

toJSON(): Pick<User, "username" | "id" | "createdAt" | "nsfw" | "linkKarma" | "commentKarma"> & object

Returns

Pick<User, "username" | "id" | "createdAt" | "nsfw" | "linkKarma" | "commentKarma"> & object