Class: User
A class representing a user.
Table of contents
Accessors
Methods
- getComments
- getModPermissionsForSubreddit
- getPosts
- toJSON
- createRelationship
- getById
- getByUsername
- getFromMetadata
- getSubredditUsersByType
- removeRelationship
- setModeratorPermissions
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
| Name | Type | Description |
|---|---|---|
options | Omit< GetCommentsByUserOptions, "username"> | Options for the request |
Returns
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
| Name | Type | Description |
|---|---|---|
subredditName | string | name 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
| Name | Type | Description |
|---|---|---|
options | Omit< GetPostsByUserOptions, "username"> | Options for the request |
Returns
A Listing of Post objects.
toJSON
▸ toJSON(): Object
Returns
Object
| Name | Type |
|---|---|
commentKarma | number |
createdAt | Date |
id | `t2_${string}` |
linkKarma | number |
modPermissionsBySubreddit | { [k: string]: T; } |
nsfw | boolean |
username | string |
createRelationship
▸ Static createRelationship(options, metadata?): Promise< void>
Parameters
| Name | Type |
|---|---|
options | CreateRelationshipOptions |
metadata? | Metadata |
Returns
Promise< void>
getById
▸ Static getById(id, metadata?): Promise< User>
Parameters
| Name | Type |
|---|---|
id | `t2_${string}` |
metadata? | Metadata |
Returns
Promise< User>
getByUsername
▸ Static getByUsername(username, metadata?): Promise< User>
Parameters
| Name | Type |
|---|---|
username | string |
metadata? | Metadata |
Returns
Promise< User>
getFromMetadata
▸ Static getFromMetadata(key, metadata?): Promise< User>
Parameters
| Name | Type |
|---|---|
key | string |
metadata? | Metadata |
Returns
Promise< User>
getSubredditUsersByType
▸ Static getSubredditUsersByType(options, metadata?): Listing< User>
Parameters
| Name | Type |
|---|---|
options | GetSubredditUsersByTypeOptions |
metadata? | Metadata |
Returns
removeRelationship
▸ Static removeRelationship(options, metadata?): Promise< void>
Parameters
| Name | Type |
|---|---|
options | RemoveRelationshipOptions |
metadata? | Metadata |
Returns
Promise< void>
setModeratorPermissions
▸ Static setModeratorPermissions(username, subredditName, permissions, metadata?): Promise< void>
Parameters
| Name | Type |
|---|---|
username | string |
subredditName | string |
permissions | ModeratorPermission[] |
metadata? | Metadata |
Returns
Promise< void>