Skip to main content

Comment

popyt


popyt / Library Exports / Comment

Class: Comment

Defined in: entities/comment.ts:5

Constructors​

Constructor​

new Comment(youtube, data, full?): Comment

Defined in: entities/comment.ts:141

Parameters​

youtube​

YouTube

data​

Schema$Comment

full?​

boolean = true

Returns​

Comment

Properties​

author​

author: object

Defined in: entities/comment.ts:46

The comment's author.

avatar​

avatar: string

The author's avatar URL.

channelId​

channelId: string

The author's channel ID.

channelUrl​

channelUrl: string

The author's channel URL.

username​

username: string

The author's YouTube username. May not be unique.


channelId?​

optional channelId?: string

Defined in: entities/comment.ts:117

The ID of the channel that uploaded the video this comment is on, if any.
Currently broken, see here.


data​

data: any

Defined in: entities/comment.ts:31

The raw data from the YouTube API of the comment.


dateEdited​

dateEdited: Date

Defined in: entities/comment.ts:111

Either the date the comment was last edited, or the date it was posted.


datePublished​

datePublished: Date

Defined in: entities/comment.ts:105

The date the comment was published.


full​

full: boolean = true

Defined in: entities/comment.ts:41

Whether or not this a full comment object.


id​

id: string

Defined in: entities/comment.ts:36

The comment's unique YouTube ID.


likes​

likes: number

Defined in: entities/comment.ts:95

The number of likes the comment has received.


parentCommentId?​

optional parentCommentId?: string

Defined in: entities/comment.ts:127

If this comment is a reply, then this is the ID of the comment it is replying to.


popular: boolean

Defined in: entities/comment.ts:90

Either YouTube thinks it's popular, or it has at least 100 likes.


rateable​

rateable: boolean

Defined in: entities/comment.ts:85

Whether or not you can like/dislike the comment.


replies​

replies: PaginatedResponse<Comment>

Defined in: entities/comment.ts:134

Replies directed to the comment. If the comment was fetched from a video, then this will be partially filled. You'll need to use Comment.fetchReplies to get all of the replies, though.


replyCount?​

optional replyCount?: number

Defined in: entities/comment.ts:139

If this comment was fetched from a video, then this is the number of replies on it.


text​

text: object

Defined in: entities/comment.ts:71

The comment's content.

displayed​

displayed: string

What YouTube displays to the user viewing the comment.

original​

original: string

The comment's plain text.


url?​

optional url?: string

Defined in: entities/comment.ts:100

The url of the comment.


videoId?​

optional videoId?: string

Defined in: entities/comment.ts:122

The ID of the video that this comment is on, if any.


youtube​

youtube: YouTube

Defined in: entities/comment.ts:26

The YouTube object used to create the comment.


endpoint​

static endpoint: string = 'comments'

Defined in: entities/comment.ts:9

The name of the endpoint used for this entity.


fields​

static fields: string

Defined in: entities/comment.ts:19

The fields to request for this entity.


part​

static part: string = 'snippet'

Defined in: entities/comment.ts:14

The parts to request for this entity.

Methods​

delete()​

delete(): Promise<void>

Defined in: entities/comment.ts:262

Deletes the comment. Must be using an access token with correct scopes.

Returns​

Promise<void>


edit()​

edit(text): Promise<Comment>

Defined in: entities/comment.ts:225

Edits the comment. Must be using an access token with correct scopes.

Parameters​

text​

string

The new text of the comment.

Returns​

Promise<Comment>


fetchReplies()​

fetchReplies(pageOptions?, parts?): Promise<PaginatedResponse<Comment>>

Defined in: entities/comment.ts:215

Fetches replies to the comment from the API.

Parameters​

pageOptions?​

PageOptions

The number of pages and maximum number of items per page. Fetches the maximum number of items allowed by the API per page by default.
Set pages to a value <=0 to fetch all.

parts?​

CommentParts

The parts of the object to fetch (saves quota if you aren't using certain properties!)

Returns​

Promise<PaginatedResponse<Comment>>


markAsSpam()​

markAsSpam(): Promise<void>

Defined in: entities/comment.ts:243

Marks the comment as spam. Must be using an access token with correct scopes.

Returns​

Promise<void>


reply()​

reply(text): Promise<Comment>

Defined in: entities/comment.ts:235

Replies to the comment. Must be using an access token with correct scopes.

Parameters​

text​

string

The text of the reply.

Returns​

Promise<Comment>


setModerationStatus()​

setModerationStatus(status?, banAuthor?): Promise<void>

Defined in: entities/comment.ts:254

Sets the comment's moderation status. Must be using an access token with correct scopes.

Parameters​

status?​

"heldForReview" | "published" | "rejected"

The status to set the comment to.

banAuthor?​

boolean = false

Whether or not to ban the author of the comment from commenting again. Defaults to false.

Returns​

Promise<void>