-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
DocChannel.ts
66 lines (60 loc) · 1.78 KB
/
DocChannel.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
59
60
61
62
63
64
65
66
import { Collection } from "@discordjs/collection";
import type { DocPayload, DocsService } from "@guildedjs/api";
import type { OptionBody } from "../../typings";
import { Channel } from "./Channel";
/**
* Represents a doc channel on Guilded
*
* @extends Channel
*/
export class DocChannel extends Channel {
/**
* The docs in this channel.
*/
readonly docs = new Collection<number, DocPayload>();
/**
* Create a new doc in this channel.
*
* @param options - The options for creating the doc.
* @returns A promise that resolves with the created doc.
*/
createDoc(options: OptionBody<DocsService["docCreate"]>): Promise<DocPayload> {
return this.client.docs.create(this.id, options);
}
/**
* Get all the docs from this channel.
*
* @returns A promise that resolves with an array of all docs.
*/
getDocs(): Promise<DocPayload[]> {
return this.client.docs.fetchMany(this.id);
}
/**
* Get a specific doc from this channel.
*
* @param docId - The ID ofDocPayload the doc to fetch.
* @returns A promise that resolves with the fetched doc.
*/
getDoc(docId: number): Promise<DocPayload> {
return this.client.docs.fetch(this.id, docId);
}
/**
* Update a specific doc in this channel.
*
* @param docId - The ID of the doc to update.
* @param options - The options for updating the doc.
* @returns A promise that resolves with the updated doc.
*/
updateDoc(docId: number, options: OptionBody<DocsService["docUpdate"]>): Promise<DocPayload> {
return this.client.docs.update(this.id, docId, options);
}
/**
* Delete a specific doc from this channel.
*
* @param docId - The ID of the doc to delete.
* @returns A promise that resolves with no data.
*/
deleteDoc(docId: number): Promise<void> {
return this.client.docs.delete(this.id, docId);
}
}