-
Notifications
You must be signed in to change notification settings - Fork 14
Comment
gatecrasher777 edited this page Jan 7, 2022
·
1 revision
Comments are constructed from the video.fetchComments()
, video.commentsText()
or comment.fetch()
commands, and are not designed to be directly constructed by users.
fetch() collects all replies to a comment (if any).
comment.fetch();
Comment objects can have the following properties. Comment objects are created from results and may have many properties undefined, giving only default values until such time as data is fetched.
comment.text (String) The comment text (utf8).
comment.isComment (boolean) Whether the comment is a direct comment on the video.
comment.isReply (boolean) Whether the comment is a reply to another comment.
comment.comment (Comment) The parent comment object of a reply or null if the comment is direct.
comment.video (Video) The video object being commented upon.
comment.id The unique YouTube comment id.
comment.data (string) or [(string)] The raw YouTube reply data fetched.
comment.transferred (number) Cumulative number of bytes of incoming data (compressed with gzip library).
comment.debugOn (boolean) default is false. Set to true to get error information in the console.
comment.results ([Item]) Array of objects fetched by the last fetch()/continued() cycle.
comment.replies ([Comment]) Array of comment objects fetched by fetch() methods.
comment.replyCount (number) Number of replies to the comment.
comment.likes (number) Number of comment/reply likes.
comment.author (string) Displayed name of the comment/reply author.
comment.published (number) Timestamp of when the comment/reply was made.
comment.channelId (string) Channel Id of comment/reply author.
comment.thumbnail (string) Url of logo/avatar of the comment author
cooment.page (number) Last page number of raw data collected on the last fetch().
Dump all comments and replies to console from newest to oldest.
await video.fetchComments({
quantity: 0,
order: 'new',
replies: true
});
video.comments.forEach ( comment => {
console.log(comment.text);
comment.forEach(reply => console.log(reply.text));
});