deno.land / x / anilist_js@0.1.0 / src / thread.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { thread as thread_query, thread_comment,} from '../graphql/thread.ts';import { req } from './utils/req.ts';
/** * Sub class for thread related functions * @since 1.0.0 * @memberof Anilist */export class Thread { /** * Gets a forum thread * @since 1.0.0 * @param {number} id The thread's id * @returns {Thread} Thread */ async get(id: number) { if (typeof id !== 'number') { throw new TypeError( 'Argument Id is required and must be of type number', ); } return await req({ query: thread_query, variables: { id: id, }, }) .then((body) => body.Thread); } /** * Gets the comments of a thread * @since 1.0.0 * @param {number} id Thread id * @param {number} [page=1] Number of the page to view * @param {number} [perPage=5] Amount of results per page * @returns {Array<ThreadComment>} Array<ThreadComment> */ async getComments(id: number, page = 1, perPage = 5) { if (typeof id !== 'number') { throw new TypeError( 'Argument Id is required and must be of type number', ); } return await req({ query: thread_comment, variables: { id, page, perPage, }, }) .then((body) => body.Page.threadComments); }}
anilist_js

Version Info

Tagged at
a year ago

External Dependencies

No external dependencies 🎉