Documentation
Library Exports.Comment
Constructors
constructor
• new Comment(youtube
, data
, full?
)
Parameters
Name | Type | Default value |
---|---|---|
youtube | YouTube | undefined |
data | any | undefined |
full | boolean | true |
Defined in
Properties
author
• author: Object
The comment's author.
Type declaration
Name | Type | Description |
---|---|---|
avatar | string | The author's avatar URL. |
channelId | string | The author's channel ID. |
channelUrl | string | The author's channel URL. |
username | string | The author's YouTube username. May not be unique. |
Defined in
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
data
• data: any
The raw data from the YouTube API of the comment.
Defined in
dateEdited
• dateEdited: Date
Either the date the comment was last edited, or the date it was posted.
Defined in
datePublished
• datePublished: Date
The date the comment was published.
Defined in
full
• full: boolean
= true
Whether or not this a full comment object.
Defined in
id
• id: string
The comment's unique YouTube ID.
Defined in
likes
• likes: number
The number of likes the comment has received.
Defined in
parentCommentId
• Optional
parentCommentId: string
If this comment is a reply, then this is the ID of the comment it is replying to.
Defined in
popular
• popular: boolean
Either YouTube thinks it's popular, or it has at least 100 likes.
Defined in
rateable
• rateable: boolean
Whether or not you can like/dislike the comment.
Defined in
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
replyCount
• Optional
replyCount: number
If this comment was fetched from a video, then this is the number of replies on it.
Defined in
text
• text: Object
The comment's content.
Type declaration
Name | Type | Description |
---|---|---|
displayed | string | What YouTube displays to the user viewing the comment. |
original | string | The comment's plain text. |
Defined in
url
• Optional
url: string
The url of the comment.
Defined in
videoId
• Optional
videoId: string
The ID of the video that this comment is on, if any.
Defined in
youtube
• youtube: YouTube
The YouTube object used to create the comment.
Defined in
endpoint
▪ Static
endpoint: string
= 'comments'
The name of the endpoint used for this entity.
Defined in
fields
▪ Static
fields: string
The fields to request for this entity.
Defined in
part
▪ Static
part: string
= 'snippet'
The parts to request for this entity.
Defined in
Methods
delete
▸ delete(): Promise
<void
>
Deletes the comment. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
edit
▸ edit(text
): Promise
<Comment
>
Edits the comment. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
text | string | The new text of the comment. |
Returns
Promise
<Comment
>
Defined in
fetchReplies
▸ fetchReplies(pageOptions?
, parts?
): Promise
<PaginatedResponse
<Comment
>>
Fetches replies to the comment from the API.
Parameters
Name | Type | Description |
---|---|---|
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
>>
Defined in
markAsSpam
▸ markAsSpam(): Promise
<void
>
Marks the comment as spam. Must be using an access token with correct scopes.
Returns
Promise
<void
>
Defined in
reply
▸ reply(text
): Promise
<Comment
>
Replies to the comment. Must be using an access token with correct scopes.
Parameters
Name | Type | Description |
---|---|---|
text | string | The text of the reply. |
Returns
Promise
<Comment
>
Defined in
setModerationStatus
▸ setModerationStatus(status?
, banAuthor?
): Promise
<void
>
Sets the comment's moderation status. Must be using an access token with correct scopes.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
status? | "rejected" | "heldForReview" | "published" | undefined | 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
>