Skip to main content
Version: 0.9

Class: User

A class representing a user.

Table of contents

Accessors

Methods

Accessors

commentKarma

get commentKarma(): number

The amount of comment karma the user has.

Returns

number


createdAt

get createdAt(): Date

The date the user was created.

Returns

Date


id

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

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

Example

't2_1w72';

Returns

`t2_${string}`


linkKarma

get linkKarma(): number

The amount of link karma the user has.

Returns

number


modPermissions

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

The permissions the user has on the subreddit.

Returns

Map< string, ModeratorPermission[]>


nsfw

get nsfw(): boolean

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

Returns

boolean


username

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

NameTypeDescription
optionsOmit< GetCommentsByUserOptions, "username">Options for the request

Returns

Listing< Comment>

A Listing of Comment objects.


getModPermissionsForSubreddit

getModPermissionsForSubreddit(subredditName): undefined | ModeratorPermission[]

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

Parameters

NameTypeDescription
subredditNamestringname of the subreddit

Returns

undefined | ModeratorPermission[]

the moderator permissions the user has on the subreddit


getPosts

getPosts(options): Listing< Post>

Get the user's posts.

Parameters

NameTypeDescription
optionsOmit< GetPostsByUserOptions, "username">Options for the request

Returns

Listing< Post>

A Listing of Post objects.


toJSON

toJSON(): Object

Returns

Object

NameType
commentKarmanumber
createdAtDate
id`t2_${string}`
linkKarmanumber
modPermissionsBySubreddit{ [k: string]: T; }
nsfwboolean
usernamestring

createRelationship

Static createRelationship(options, metadata?): Promise< void>

Parameters

NameType
optionsCreateRelationshipOptions
metadata?Metadata

Returns

Promise< void>


getById

Static getById(id, metadata?): Promise< User>

Parameters

NameType
id`t2_${string}`
metadata?Metadata

Returns

Promise< User>


getByUsername

Static getByUsername(username, metadata?): Promise< User>

Parameters

NameType
usernamestring
metadata?Metadata

Returns

Promise< User>


getFromMetadata

Static getFromMetadata(key, metadata?): Promise< User>

Parameters

NameType
keystring
metadata?Metadata

Returns

Promise< User>


getSubredditUsersByType

Static getSubredditUsersByType(options, metadata?): Listing< User>

Parameters

NameType
optionsGetSubredditUsersByTypeOptions
metadata?Metadata

Returns

Listing< User>


removeRelationship

Static removeRelationship(options, metadata?): Promise< void>

Parameters

NameType
optionsRemoveRelationshipOptions
metadata?Metadata

Returns

Promise< void>


setModeratorPermissions

Static setModeratorPermissions(username, subredditName, permissions, metadata?): Promise< void>

Parameters

NameType
usernamestring
subredditNamestring
permissionsModeratorPermission[]
metadata?Metadata

Returns

Promise< void>