Skip to main content

Documentation

Library Exports.Comment

Constructors

constructor

new Comment(youtube, data, full?)

Parameters

NameTypeDefault value
youtubeYouTubeundefined
dataanyundefined
fullbooleantrue

Defined in

entities/comment.ts:140

Properties

author

author: Object

The comment's author.

Type declaration

NameTypeDescription
avatarstringThe author's avatar URL.
channelIdstringThe author's channel ID.
channelUrlstringThe author's channel URL.
usernamestringThe author's YouTube username. May not be unique.

Defined in

entities/comment.ts:45


channelId

Optional channelId: string

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

Defined in

entities/comment.ts:116


data

data: any

The raw data from the YouTube API of the comment.

Defined in

entities/comment.ts:30


dateEdited

dateEdited: Date

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

Defined in

entities/comment.ts:110


datePublished

datePublished: Date

The date the comment was published.

Defined in

entities/comment.ts:104


full

full: boolean = true

Whether or not this a full comment object.

Defined in

entities/comment.ts:40


id

id: string

The comment's unique YouTube ID.

Defined in

entities/comment.ts:35


likes

likes: number

The number of likes the comment has received.

Defined in

entities/comment.ts:94


parentCommentId

Optional parentCommentId: string

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

Defined in

entities/comment.ts:126


popular: boolean

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

Defined in

entities/comment.ts:89


rateable

rateable: boolean

Whether or not you can like/dislike the comment.

Defined in

entities/comment.ts:84


replies

replies: PaginatedResponse<Comment>

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.

Defined in

entities/comment.ts:133


replyCount

Optional replyCount: number

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

Defined in

entities/comment.ts:138


text

text: Object

The comment's content.

Type declaration

NameTypeDescription
displayedstringWhat YouTube displays to the user viewing the comment.
originalstringThe comment's plain text.

Defined in

entities/comment.ts:70


url

Optional url: string

The url of the comment.

Defined in

entities/comment.ts:99


videoId

Optional videoId: string

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

Defined in

entities/comment.ts:121


youtube

youtube: YouTube

The YouTube object used to create the comment.

Defined in

entities/comment.ts:25


endpoint

Static endpoint: string = 'comments'

The name of the endpoint used for this entity.

Defined in

entities/comment.ts:8


fields

Static fields: string

The fields to request for this entity.

Defined in

entities/comment.ts:18


part

Static part: string = 'snippet'

The parts to request for this entity.

Defined in

entities/comment.ts:13

Methods

delete

delete(): Promise<void>

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

Returns

Promise<void>

Defined in

entities/comment.ts:256


edit

edit(text): Promise<Comment>

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

Parameters

NameTypeDescription
textstringThe new text of the comment.

Returns

Promise<Comment>

Defined in

entities/comment.ts:219


fetchReplies

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

Fetches replies to the comment from the API.

Parameters

NameTypeDescription
pageOptions?PageOptionsThe 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?CommentPartsThe parts of the object to fetch (saves quota if you aren't using certain properties!)

Returns

Promise<PaginatedResponse<Comment>>

Defined in

entities/comment.ts:209


markAsSpam

markAsSpam(): Promise<void>

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

Returns

Promise<void>

Defined in

entities/comment.ts:237


reply

reply(text): Promise<Comment>

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

Parameters

NameTypeDescription
textstringThe text of the reply.

Returns

Promise<Comment>

Defined in

entities/comment.ts:229


setModerationStatus

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

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

Parameters

NameTypeDefault valueDescription
status?"rejected" | "heldForReview" | "published"undefinedThe status to set the comment to.
banAuthorbooleanfalseWhether or not to ban the author of the comment from commenting again. Defaults to false.

Returns

Promise<void>

Defined in

entities/comment.ts:248