UNPKG

2.12 kBTypeScriptView Raw
1import { TextChannel } from 'discord.js';
2export interface Endpoint {
3 type: 'messenger' | 'discord';
4 id: string;
5 name?: string;
6 channel?: TextChannel;
7 readonly?: boolean;
8}
9export interface ChannelEndpoint extends Endpoint {
10 channel: TextChannel;
11}
12export default class Connection {
13 name: string;
14 endpoints: Endpoint[];
15 constructor(name: string, endpoints?: Endpoint[]);
16 static isThread(endpoint: Endpoint): boolean;
17 static isChannel(endpoint: Endpoint): boolean;
18 addThread({ id, name }: {
19 id: string;
20 name: string;
21 }): this;
22 addChannel({ id, name }: {
23 id: string;
24 name: string;
25 }): this;
26 addEndpoint({ id, type, readonly }: {
27 id: string;
28 type: 'discord' | 'messenger';
29 readonly?: boolean;
30 }): Promise<void>;
31 has(id: string): boolean;
32 getWritableEndpoints(): Endpoint[];
33 getThreads(): Endpoint[];
34 getWritableThreads(): Endpoint[];
35 getOtherWritableThreads(id: string): Endpoint[];
36 getChannels(): ChannelEndpoint[];
37 getWritableChannels(): ChannelEndpoint[];
38 getOtherWritableChannels(id: string): ChannelEndpoint[];
39 checkChannelRenames(name: string): Promise<this>;
40 hasEndpoint(id: string): boolean;
41 markEndpointAsReadonly(id: string, readonly: boolean): this;
42 removeEndpoint(id: string): Promise<this>;
43 getPrintable(): string;
44 rename(newName: string): Promise<this>;
45 delete(): Promise<void>;
46 save(): Promise<this>;
47 toYAMLObject(): {
48 [x: string]: {
49 type: "messenger" | "discord";
50 id: string;
51 name: string | undefined;
52 readonly: boolean | undefined;
53 }[];
54 };
55 toObject(): {
56 name: string;
57 endpoints: {
58 type: "messenger" | "discord";
59 id: string;
60 name: string | undefined;
61 readonly: boolean | undefined;
62 }[];
63 };
64 readonly cleanEndpoints: {
65 type: "messenger" | "discord";
66 id: string;
67 name: string | undefined;
68 readonly: boolean | undefined;
69 }[];
70}