@theophilusdev/conduit 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -38
- package/docs/DOCS.md +122 -96
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
> A lightweight TypeScript wrapper around [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial) with a clean, middleware-based event system.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
|
-
|
|
9
|
-
await conduit.login({ appstate });
|
|
8
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
const client = new ConduitClient({ listenEvents: true });
|
|
11
|
+
await client.login({ appstate });
|
|
12
|
+
|
|
13
|
+
client.on("message:create", async (ctx) => {
|
|
12
14
|
await ctx.reply(`hey, you said: ${ctx.body}`);
|
|
13
15
|
});
|
|
14
16
|
```
|
|
@@ -22,18 +24,19 @@ npm install @theophilusdev/conduit
|
|
|
22
24
|
## Quick Start
|
|
23
25
|
|
|
24
26
|
```ts
|
|
25
|
-
import { ConduitClient } from "conduit";
|
|
27
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
26
28
|
import appstate from "./appstate.json" assert { type: "json" };
|
|
27
29
|
|
|
28
|
-
const
|
|
30
|
+
const client = new ConduitClient({ listenEvents: true });
|
|
29
31
|
|
|
30
|
-
await
|
|
32
|
+
await client.login({ appstate });
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
client.on("message:create", async (ctx, next) => {
|
|
33
35
|
if (ctx.body === "ping") {
|
|
34
36
|
await ctx.reply("pong");
|
|
35
37
|
return;
|
|
36
38
|
}
|
|
39
|
+
|
|
37
40
|
await next();
|
|
38
41
|
});
|
|
39
42
|
```
|
|
@@ -50,56 +53,67 @@ Pass **one** of the following to `.login()`:
|
|
|
50
53
|
|
|
51
54
|
```ts
|
|
52
55
|
// appstate (recommended)
|
|
53
|
-
await
|
|
56
|
+
await client.login({ appstate: [...] });
|
|
54
57
|
|
|
55
58
|
// raw cookies
|
|
56
|
-
await
|
|
59
|
+
await client.login({ cookies: "c_user=...; xs=..." });
|
|
57
60
|
|
|
58
61
|
// email/password (not recommended)
|
|
59
|
-
await
|
|
62
|
+
await client.login({
|
|
63
|
+
account: { email: "...", password: "..." },
|
|
64
|
+
});
|
|
60
65
|
```
|
|
61
66
|
|
|
62
67
|
## Events
|
|
63
68
|
|
|
64
|
-
Register handlers with `.on(event, ...middlewares)`.
|
|
69
|
+
Register handlers with `.on(event, ...middlewares)`.
|
|
70
|
+
|
|
71
|
+
Handlers receive a context object and an optional `next()` function for middleware chaining.
|
|
65
72
|
|
|
66
|
-
All events include
|
|
73
|
+
All events include:
|
|
74
|
+
|
|
75
|
+
- `send(body)`
|
|
76
|
+
|
|
77
|
+
Message events additionally include:
|
|
78
|
+
|
|
79
|
+
- `reply(body)`
|
|
80
|
+
- `react(emoji)`
|
|
67
81
|
|
|
68
82
|
### Message Events
|
|
69
83
|
|
|
70
|
-
| Event |
|
|
71
|
-
| ----------------- |
|
|
72
|
-
| `message:create` | New message received
|
|
73
|
-
| `message:respond` | Reply to an existing message
|
|
74
|
-
| `message:remove` | Message unsent by sender
|
|
75
|
-
| `message:react` | Reaction added or removed
|
|
76
|
-
| `message:writing` |
|
|
77
|
-
| `message:read` | Thread or message marked as read
|
|
84
|
+
| Event | Description |
|
|
85
|
+
| ----------------- | ------------------------------------------------ |
|
|
86
|
+
| `message:create` | New message received |
|
|
87
|
+
| `message:respond` | Reply to an existing message |
|
|
88
|
+
| `message:remove` | Message unsent by sender |
|
|
89
|
+
| `message:react` | Reaction added or removed |
|
|
90
|
+
| `message:writing` | Typing indicator (requires `listenTyping: true`) |
|
|
91
|
+
| `message:read` | Thread or message marked as read |
|
|
78
92
|
|
|
79
93
|
### User Events
|
|
80
94
|
|
|
81
|
-
| Event |
|
|
95
|
+
| Event | Description |
|
|
82
96
|
| ------------- | -------------------------------------------- |
|
|
83
97
|
| `user:create` | User added to a group thread |
|
|
84
98
|
| `user:remove` | User left or was removed from a group thread |
|
|
85
99
|
|
|
86
100
|
### Thread Events
|
|
87
101
|
|
|
88
|
-
| Event |
|
|
89
|
-
| ------------------------- |
|
|
90
|
-
| `thread:update` |
|
|
91
|
-
| `thread:title_change` | Group title updated
|
|
92
|
-
| `thread:photo_replaced` | Group photo changed
|
|
93
|
-
| `thread:theme_changed` | Chat theme
|
|
94
|
-
| `thread:nickname_changed` |
|
|
95
|
-
| `thread:admin_changed` |
|
|
102
|
+
| Event | Description |
|
|
103
|
+
| ------------------------- | ---------------------------- |
|
|
104
|
+
| `thread:update` | Catch-all for thread updates |
|
|
105
|
+
| `thread:title_change` | Group title updated |
|
|
106
|
+
| `thread:photo_replaced` | Group photo changed |
|
|
107
|
+
| `thread:theme_changed` | Chat theme changed |
|
|
108
|
+
| `thread:nickname_changed` | Participant nickname updated |
|
|
109
|
+
| `thread:admin_changed` | Admin role changed |
|
|
96
110
|
|
|
97
111
|
## Middleware
|
|
98
112
|
|
|
99
|
-
`.on()` accepts multiple handlers. Each must call `next()` to
|
|
113
|
+
`.on()` accepts multiple handlers. Each must call `next()` to continue the chain.
|
|
100
114
|
|
|
101
115
|
```ts
|
|
102
|
-
|
|
116
|
+
client.on(
|
|
103
117
|
"message:create",
|
|
104
118
|
async (ctx, next) => {
|
|
105
119
|
console.log("middleware 1");
|
|
@@ -114,26 +128,31 @@ conduit.on(
|
|
|
114
128
|
|
|
115
129
|
## Raw FCA Access
|
|
116
130
|
|
|
117
|
-
|
|
131
|
+
Drop down to FCA when needed:
|
|
118
132
|
|
|
119
133
|
```ts
|
|
120
134
|
// raw FCA event
|
|
121
|
-
|
|
135
|
+
client.onFca("presence", async (data) => {
|
|
122
136
|
console.log(data);
|
|
123
137
|
});
|
|
124
138
|
|
|
125
|
-
// raw FCA
|
|
126
|
-
|
|
139
|
+
// raw FCA API (no type safety)
|
|
140
|
+
client.api.getThreadList(10, null, ["INBOX"]);
|
|
127
141
|
```
|
|
128
142
|
|
|
129
143
|
## API Reference
|
|
130
144
|
|
|
131
|
-
See [docs/DOCS.md](docs/DOCS.md) for
|
|
145
|
+
See [docs/DOCS.md](docs/DOCS.md) for full API details:
|
|
146
|
+
|
|
147
|
+
- `client.messages`
|
|
148
|
+
- `client.threads`
|
|
149
|
+
- `client.users`
|
|
150
|
+
- `client.account`
|
|
132
151
|
|
|
133
152
|
## License
|
|
134
153
|
|
|
135
|
-
GNU GPL v3 ©
|
|
154
|
+
GNU GPL v3 © theophilusdev
|
|
136
155
|
|
|
137
156
|
---
|
|
138
157
|
|
|
139
|
-
Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial).
|
|
158
|
+
Built on top of [`@dongdev/fca-unofficial`](https://github.com/dongp06/fca-unofficial).
|
package/docs/DOCS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Conduit — API Reference
|
|
2
2
|
|
|
3
|
-
Full reference for all
|
|
3
|
+
Full reference for all APIs exposed by `ConduitClient`.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -16,28 +16,33 @@ Full reference for all namespaced APIs exposed by `ConduitClient`.
|
|
|
16
16
|
## ConduitClient
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
|
-
import { ConduitClient } from "conduit";
|
|
19
|
+
import { ConduitClient } from "@theophilusdev/conduit";
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
await
|
|
21
|
+
const client = new ConduitClient(config);
|
|
22
|
+
await client.login(credentials);
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
---
|
|
26
|
+
|
|
25
27
|
### Constructor
|
|
26
28
|
|
|
27
29
|
```ts
|
|
28
30
|
new ConduitClient(config: ConduitClientConfig)
|
|
29
31
|
```
|
|
30
32
|
|
|
31
|
-
|
|
33
|
+
Creates a new Conduit client instance.
|
|
34
|
+
|
|
35
|
+
- Extends `MessengerBotOptions` from `@dongdev/fca-unofficial`
|
|
36
|
+
- `logLevel` defaults to `"silent"`
|
|
32
37
|
|
|
33
38
|
---
|
|
34
39
|
|
|
35
40
|
### `.login(credentials)`
|
|
36
41
|
|
|
37
|
-
Authenticates with Messenger and
|
|
42
|
+
Authenticates with Messenger and initializes the client.
|
|
38
43
|
|
|
39
44
|
```ts
|
|
40
|
-
await
|
|
45
|
+
await client.login(credentials: ConduitCredentials): Promise<ConduitClient>
|
|
41
46
|
```
|
|
42
47
|
|
|
43
48
|
Returns the client instance for chaining.
|
|
@@ -46,14 +51,14 @@ Returns the client instance for chaining.
|
|
|
46
51
|
|
|
47
52
|
### `.on(event, ...middlewares)`
|
|
48
53
|
|
|
49
|
-
Registers one or more middleware handlers for a Conduit event.
|
|
54
|
+
Registers one or more middleware handlers for a Conduit event.
|
|
50
55
|
|
|
51
56
|
```ts
|
|
52
|
-
|
|
57
|
+
client.on(event: keyof ConduitEvents, ...middlewares: Middleware[]): this
|
|
53
58
|
```
|
|
54
59
|
|
|
55
60
|
```ts
|
|
56
|
-
|
|
61
|
+
client.on("message:create", async (ctx, next) => {
|
|
57
62
|
await ctx.reply("hello!");
|
|
58
63
|
await next();
|
|
59
64
|
});
|
|
@@ -63,27 +68,33 @@ conduit.on("message:create", async (ctx, next) => {
|
|
|
63
68
|
|
|
64
69
|
### `.onFca(event, ...middlewares)`
|
|
65
70
|
|
|
66
|
-
Registers middleware directly
|
|
71
|
+
Registers middleware directly on raw FCA events.
|
|
67
72
|
|
|
68
73
|
```ts
|
|
69
|
-
|
|
74
|
+
client.onFca(event: string, ...middlewares): this
|
|
70
75
|
```
|
|
71
76
|
|
|
72
77
|
---
|
|
73
78
|
|
|
74
79
|
### `.api`
|
|
75
80
|
|
|
76
|
-
Direct access to the raw FCA
|
|
81
|
+
Direct access to the raw FCA API.
|
|
77
82
|
|
|
78
83
|
```ts
|
|
79
|
-
|
|
84
|
+
client.api.getThreadList(10, null, ["INBOX"]);
|
|
80
85
|
```
|
|
81
86
|
|
|
82
87
|
---
|
|
83
88
|
|
|
84
89
|
## client.messages
|
|
85
90
|
|
|
86
|
-
Accessible via
|
|
91
|
+
Accessible via:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
client.messages;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Handles message-level operations.
|
|
87
98
|
|
|
88
99
|
---
|
|
89
100
|
|
|
@@ -92,27 +103,27 @@ Accessible via `conduit.messages`. Handles all message-level operations.
|
|
|
92
103
|
Sends a plain text message to a thread.
|
|
93
104
|
|
|
94
105
|
```ts
|
|
95
|
-
await
|
|
106
|
+
await client.messages.send("hello", threadID);
|
|
96
107
|
```
|
|
97
108
|
|
|
98
109
|
---
|
|
99
110
|
|
|
100
111
|
### `.reply(body, threadID, messageID)`
|
|
101
112
|
|
|
102
|
-
Sends a
|
|
113
|
+
Sends a reply to a specific message.
|
|
103
114
|
|
|
104
115
|
```ts
|
|
105
|
-
await
|
|
116
|
+
await client.messages.reply("got it", threadID, messageID);
|
|
106
117
|
```
|
|
107
118
|
|
|
108
119
|
---
|
|
109
120
|
|
|
110
121
|
### `.edit(messageID, body)`
|
|
111
122
|
|
|
112
|
-
Edits an existing message
|
|
123
|
+
Edits an existing message.
|
|
113
124
|
|
|
114
125
|
```ts
|
|
115
|
-
await
|
|
126
|
+
await client.messages.edit(messageID, "updated text");
|
|
116
127
|
```
|
|
117
128
|
|
|
118
129
|
---
|
|
@@ -122,7 +133,7 @@ await conduit.messages.edit(messageID, "updated text");
|
|
|
122
133
|
Retracts a message sent by the bot.
|
|
123
134
|
|
|
124
135
|
```ts
|
|
125
|
-
await
|
|
136
|
+
await client.messages.unsend(messageID);
|
|
126
137
|
```
|
|
127
138
|
|
|
128
139
|
---
|
|
@@ -132,7 +143,7 @@ await conduit.messages.unsend(messageID);
|
|
|
132
143
|
Deletes a message.
|
|
133
144
|
|
|
134
145
|
```ts
|
|
135
|
-
await
|
|
146
|
+
await client.messages.delete(messageID);
|
|
136
147
|
```
|
|
137
148
|
|
|
138
149
|
---
|
|
@@ -142,17 +153,17 @@ await conduit.messages.delete(messageID);
|
|
|
142
153
|
Adds or removes a reaction on a message.
|
|
143
154
|
|
|
144
155
|
```ts
|
|
145
|
-
await
|
|
156
|
+
await client.messages.react("👍", messageID, threadID);
|
|
146
157
|
```
|
|
147
158
|
|
|
148
159
|
---
|
|
149
160
|
|
|
150
161
|
### `.sendTypingIndicator(threadID)`
|
|
151
162
|
|
|
152
|
-
Sends a typing indicator
|
|
163
|
+
Sends a typing indicator.
|
|
153
164
|
|
|
154
165
|
```ts
|
|
155
|
-
await
|
|
166
|
+
await client.messages.sendTypingIndicator(threadID);
|
|
156
167
|
```
|
|
157
168
|
|
|
158
169
|
---
|
|
@@ -162,205 +173,209 @@ await conduit.messages.sendTypingIndicator(threadID);
|
|
|
162
173
|
Marks a message as read.
|
|
163
174
|
|
|
164
175
|
```ts
|
|
165
|
-
await
|
|
176
|
+
await client.messages.markAsRead(messageID);
|
|
166
177
|
```
|
|
167
178
|
|
|
168
179
|
---
|
|
169
180
|
|
|
170
181
|
### `.uploadAttachment(file)`
|
|
171
182
|
|
|
172
|
-
Uploads a file attachment
|
|
183
|
+
Uploads a file attachment.
|
|
173
184
|
|
|
174
185
|
```ts
|
|
175
|
-
const attachment = await
|
|
186
|
+
const attachment = await client.messages.uploadAttachment(stream);
|
|
176
187
|
```
|
|
177
188
|
|
|
178
189
|
---
|
|
179
190
|
|
|
180
191
|
### `.forwardAttachment(attachmentID, threadID)`
|
|
181
192
|
|
|
182
|
-
Forwards an
|
|
193
|
+
Forwards an attachment to another thread.
|
|
183
194
|
|
|
184
195
|
```ts
|
|
185
|
-
await
|
|
196
|
+
await client.messages.forwardAttachment(attachmentID, threadID);
|
|
186
197
|
```
|
|
187
198
|
|
|
188
199
|
---
|
|
189
200
|
|
|
190
201
|
### `.shareContact(userID, threadID)`
|
|
191
202
|
|
|
192
|
-
Shares a contact card
|
|
203
|
+
Shares a contact card.
|
|
193
204
|
|
|
194
205
|
```ts
|
|
195
|
-
await
|
|
206
|
+
await client.messages.shareContact(userID, threadID);
|
|
196
207
|
```
|
|
197
208
|
|
|
198
209
|
---
|
|
199
210
|
|
|
200
211
|
### `.changeThreadColor(color, threadID)`
|
|
201
212
|
|
|
202
|
-
Changes
|
|
213
|
+
Changes thread color.
|
|
203
214
|
|
|
204
215
|
```ts
|
|
205
|
-
await
|
|
216
|
+
await client.messages.changeThreadColor("#FF0000", threadID);
|
|
206
217
|
```
|
|
207
218
|
|
|
208
219
|
---
|
|
209
220
|
|
|
210
221
|
### `.changeThreadEmoji(emoji, threadID)`
|
|
211
222
|
|
|
212
|
-
Changes
|
|
223
|
+
Changes thread emoji.
|
|
213
224
|
|
|
214
225
|
```ts
|
|
215
|
-
await
|
|
226
|
+
await client.messages.changeThreadEmoji("🔥", threadID);
|
|
216
227
|
```
|
|
217
228
|
|
|
218
229
|
---
|
|
219
230
|
|
|
220
231
|
### `.getMessage(messageID)`
|
|
221
232
|
|
|
222
|
-
Fetches a
|
|
233
|
+
Fetches a message by ID.
|
|
223
234
|
|
|
224
235
|
```ts
|
|
225
|
-
const message = await
|
|
236
|
+
const message = await client.messages.getMessage(messageID);
|
|
226
237
|
```
|
|
227
238
|
|
|
228
239
|
---
|
|
229
240
|
|
|
230
241
|
### `.getThreadColors()`
|
|
231
242
|
|
|
232
|
-
Returns
|
|
243
|
+
Returns available thread colors.
|
|
233
244
|
|
|
234
245
|
```ts
|
|
235
|
-
const colors = await
|
|
246
|
+
const colors = await client.messages.getThreadColors();
|
|
236
247
|
```
|
|
237
248
|
|
|
238
249
|
---
|
|
239
250
|
|
|
240
251
|
## client.threads
|
|
241
252
|
|
|
242
|
-
Accessible via
|
|
253
|
+
Accessible via:
|
|
254
|
+
|
|
255
|
+
```ts
|
|
256
|
+
client.threads;
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Handles thread-level operations.
|
|
243
260
|
|
|
244
261
|
---
|
|
245
262
|
|
|
246
263
|
### `.getInfo(threadID)`
|
|
247
264
|
|
|
248
|
-
Fetches
|
|
265
|
+
Fetches thread information.
|
|
249
266
|
|
|
250
267
|
```ts
|
|
251
|
-
const info = await
|
|
268
|
+
const info = await client.threads.getInfo(threadID);
|
|
252
269
|
```
|
|
253
270
|
|
|
254
271
|
---
|
|
255
272
|
|
|
256
273
|
### `.getList(limit, cursor, folders)`
|
|
257
274
|
|
|
258
|
-
Fetches a
|
|
275
|
+
Fetches a list of threads.
|
|
259
276
|
|
|
260
277
|
```ts
|
|
261
|
-
const threads = await
|
|
278
|
+
const threads = await client.threads.getList(10, null, ["INBOX"]);
|
|
262
279
|
```
|
|
263
280
|
|
|
264
281
|
---
|
|
265
282
|
|
|
266
283
|
### `.getHistory(threadID, limit)`
|
|
267
284
|
|
|
268
|
-
Fetches message history
|
|
285
|
+
Fetches message history.
|
|
269
286
|
|
|
270
287
|
```ts
|
|
271
|
-
const history = await
|
|
288
|
+
const history = await client.threads.getHistory(threadID, 20);
|
|
272
289
|
```
|
|
273
290
|
|
|
274
291
|
---
|
|
275
292
|
|
|
276
293
|
### `.search(query)`
|
|
277
294
|
|
|
278
|
-
Searches
|
|
295
|
+
Searches threads.
|
|
279
296
|
|
|
280
297
|
```ts
|
|
281
|
-
const results = await
|
|
298
|
+
const results = await client.threads.search("dev chat");
|
|
282
299
|
```
|
|
283
300
|
|
|
284
301
|
---
|
|
285
302
|
|
|
286
303
|
### `.createGroup(userIDs, name?)`
|
|
287
304
|
|
|
288
|
-
Creates a
|
|
305
|
+
Creates a group conversation.
|
|
289
306
|
|
|
290
307
|
```ts
|
|
291
|
-
const thread = await
|
|
308
|
+
const thread = await client.threads.createGroup(["uid1", "uid2"], "my group");
|
|
292
309
|
```
|
|
293
310
|
|
|
294
311
|
---
|
|
295
312
|
|
|
296
313
|
### `.addUser(userID, threadID)`
|
|
297
314
|
|
|
298
|
-
Adds a user to
|
|
315
|
+
Adds a user to a thread.
|
|
299
316
|
|
|
300
317
|
```ts
|
|
301
|
-
await
|
|
318
|
+
await client.threads.addUser(userID, threadID);
|
|
302
319
|
```
|
|
303
320
|
|
|
304
321
|
---
|
|
305
322
|
|
|
306
323
|
### `.removeUser(userID, threadID)`
|
|
307
324
|
|
|
308
|
-
Removes a user from a
|
|
325
|
+
Removes a user from a thread.
|
|
309
326
|
|
|
310
327
|
```ts
|
|
311
|
-
await
|
|
328
|
+
await client.threads.removeUser(userID, threadID);
|
|
312
329
|
```
|
|
313
330
|
|
|
314
331
|
---
|
|
315
332
|
|
|
316
333
|
### `.changeAdminStatus(userID, threadID, admin)`
|
|
317
334
|
|
|
318
|
-
|
|
335
|
+
Changes admin status.
|
|
319
336
|
|
|
320
337
|
```ts
|
|
321
|
-
await
|
|
322
|
-
await conduit.threads.changeAdminStatus(userID, threadID, false); // demote
|
|
338
|
+
await client.threads.changeAdminStatus(userID, threadID, true);
|
|
323
339
|
```
|
|
324
340
|
|
|
325
341
|
---
|
|
326
342
|
|
|
327
343
|
### `.changeGroupImage(image, threadID)`
|
|
328
344
|
|
|
329
|
-
Updates
|
|
345
|
+
Updates group image.
|
|
330
346
|
|
|
331
347
|
```ts
|
|
332
|
-
await
|
|
348
|
+
await client.threads.changeGroupImage(stream, threadID);
|
|
333
349
|
```
|
|
334
350
|
|
|
335
351
|
---
|
|
336
352
|
|
|
337
353
|
### `.changeNickname(nickname, threadID, userID)`
|
|
338
354
|
|
|
339
|
-
Sets
|
|
355
|
+
Sets nickname.
|
|
340
356
|
|
|
341
357
|
```ts
|
|
342
|
-
await
|
|
343
|
-
await conduit.threads.changeNickname("", threadID, userID); // clear
|
|
358
|
+
await client.threads.changeNickname("nick", threadID, userID);
|
|
344
359
|
```
|
|
345
360
|
|
|
346
361
|
---
|
|
347
362
|
|
|
348
363
|
### `.setTitle(title, threadID)`
|
|
349
364
|
|
|
350
|
-
Changes
|
|
365
|
+
Changes thread title.
|
|
351
366
|
|
|
352
367
|
```ts
|
|
353
|
-
await
|
|
368
|
+
await client.threads.setTitle("new title", threadID);
|
|
354
369
|
```
|
|
355
370
|
|
|
356
371
|
---
|
|
357
372
|
|
|
358
373
|
### `.createPoll(title, threadID, options)`
|
|
359
374
|
|
|
360
|
-
Creates a poll
|
|
375
|
+
Creates a poll.
|
|
361
376
|
|
|
362
377
|
```ts
|
|
363
|
-
await
|
|
378
|
+
await client.threads.createPoll("Favourite language?", threadID, [
|
|
364
379
|
"TypeScript",
|
|
365
380
|
"Python",
|
|
366
381
|
]);
|
|
@@ -373,81 +388,89 @@ await conduit.threads.createPoll("Favourite language?", threadID, [
|
|
|
373
388
|
Deletes a thread.
|
|
374
389
|
|
|
375
390
|
```ts
|
|
376
|
-
await
|
|
391
|
+
await client.threads.delete(threadID);
|
|
377
392
|
```
|
|
378
393
|
|
|
379
394
|
---
|
|
380
395
|
|
|
381
396
|
### `.mute(threadID, muteUntil)`
|
|
382
397
|
|
|
383
|
-
Mutes or unmutes
|
|
398
|
+
Mutes or unmutes a thread.
|
|
384
399
|
|
|
385
400
|
```ts
|
|
386
|
-
await
|
|
387
|
-
await
|
|
401
|
+
await client.threads.mute(threadID, -1);
|
|
402
|
+
await client.threads.mute(threadID, 0);
|
|
388
403
|
```
|
|
389
404
|
|
|
390
405
|
---
|
|
391
406
|
|
|
392
407
|
### `.handleMessageRequest(threadID, accept)`
|
|
393
408
|
|
|
394
|
-
|
|
409
|
+
Handles message requests.
|
|
395
410
|
|
|
396
411
|
```ts
|
|
397
|
-
await
|
|
412
|
+
await client.threads.handleMessageRequest(threadID, true);
|
|
398
413
|
```
|
|
399
414
|
|
|
400
415
|
---
|
|
401
416
|
|
|
402
417
|
## client.users
|
|
403
418
|
|
|
404
|
-
Accessible via
|
|
419
|
+
Accessible via:
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
client.users;
|
|
423
|
+
```
|
|
405
424
|
|
|
406
425
|
---
|
|
407
426
|
|
|
408
427
|
### `.getInfo(userID)`
|
|
409
428
|
|
|
410
|
-
Fetches info
|
|
429
|
+
Fetches user info.
|
|
411
430
|
|
|
412
431
|
```ts
|
|
413
|
-
const user = await
|
|
414
|
-
const users = await
|
|
432
|
+
const user = await client.users.getInfo("uid");
|
|
433
|
+
const users = await client.users.getInfo(["uid1", "uid2"]);
|
|
415
434
|
```
|
|
416
435
|
|
|
417
436
|
---
|
|
418
437
|
|
|
419
438
|
### `.getID(vanity)`
|
|
420
439
|
|
|
421
|
-
Resolves
|
|
440
|
+
Resolves username to ID.
|
|
422
441
|
|
|
423
442
|
```ts
|
|
424
|
-
const id = await
|
|
443
|
+
const id = await client.users.getID("zuck");
|
|
425
444
|
```
|
|
426
445
|
|
|
427
446
|
---
|
|
428
447
|
|
|
429
448
|
### `.getFriendsList()`
|
|
430
449
|
|
|
431
|
-
Returns
|
|
450
|
+
Returns friends list.
|
|
432
451
|
|
|
433
452
|
```ts
|
|
434
|
-
const friends = await
|
|
453
|
+
const friends = await client.users.getFriendsList();
|
|
435
454
|
```
|
|
436
455
|
|
|
437
456
|
---
|
|
438
457
|
|
|
439
458
|
## client.account
|
|
440
459
|
|
|
441
|
-
Accessible via
|
|
460
|
+
Accessible via:
|
|
461
|
+
|
|
462
|
+
```ts
|
|
463
|
+
client.account;
|
|
464
|
+
```
|
|
442
465
|
|
|
443
466
|
---
|
|
444
467
|
|
|
445
468
|
### `.getCurrentUserID()`
|
|
446
469
|
|
|
447
|
-
Returns
|
|
470
|
+
Returns current user ID.
|
|
448
471
|
|
|
449
472
|
```ts
|
|
450
|
-
const myID =
|
|
473
|
+
const myID = client.account.getCurrentUserID();
|
|
451
474
|
```
|
|
452
475
|
|
|
453
476
|
---
|
|
@@ -457,46 +480,43 @@ const myID = conduit.account.getCurrentUserID();
|
|
|
457
480
|
Blocks or unblocks a user.
|
|
458
481
|
|
|
459
482
|
```ts
|
|
460
|
-
await
|
|
461
|
-
await conduit.account.blockUser(userID, false); // unblock
|
|
483
|
+
await client.account.blockUser(userID, true);
|
|
462
484
|
```
|
|
463
485
|
|
|
464
486
|
---
|
|
465
487
|
|
|
466
488
|
### `.handleFriendRequest(userID, accept)`
|
|
467
489
|
|
|
468
|
-
|
|
490
|
+
Handles friend requests.
|
|
469
491
|
|
|
470
492
|
```ts
|
|
471
|
-
await
|
|
493
|
+
await client.account.handleFriendRequest(userID, true);
|
|
472
494
|
```
|
|
473
495
|
|
|
474
496
|
---
|
|
475
497
|
|
|
476
498
|
### `.unfriend(userID)`
|
|
477
499
|
|
|
478
|
-
Removes a
|
|
500
|
+
Removes a friend.
|
|
479
501
|
|
|
480
502
|
```ts
|
|
481
|
-
await
|
|
503
|
+
await client.account.unfriend(userID);
|
|
482
504
|
```
|
|
483
505
|
|
|
484
506
|
---
|
|
485
507
|
|
|
486
508
|
### `.logout()`
|
|
487
509
|
|
|
488
|
-
|
|
510
|
+
Logs out of the session.
|
|
489
511
|
|
|
490
512
|
```ts
|
|
491
|
-
await
|
|
513
|
+
await client.account.logout();
|
|
492
514
|
```
|
|
493
515
|
|
|
494
516
|
---
|
|
495
517
|
|
|
496
518
|
## Types
|
|
497
519
|
|
|
498
|
-
Key types exported from conduit. See `src/types.ts` for the full source.
|
|
499
|
-
|
|
500
520
|
### `ConduitCredentials`
|
|
501
521
|
|
|
502
522
|
```ts
|
|
@@ -510,6 +530,8 @@ interface ConduitCredentials {
|
|
|
510
530
|
}
|
|
511
531
|
```
|
|
512
532
|
|
|
533
|
+
---
|
|
534
|
+
|
|
513
535
|
### `Message`
|
|
514
536
|
|
|
515
537
|
```ts
|
|
@@ -525,6 +547,8 @@ interface Message {
|
|
|
525
547
|
}
|
|
526
548
|
```
|
|
527
549
|
|
|
550
|
+
---
|
|
551
|
+
|
|
528
552
|
### `Middleware<K>`
|
|
529
553
|
|
|
530
554
|
```ts
|
|
@@ -534,6 +558,8 @@ type Middleware<K extends keyof ConduitEvents> = (
|
|
|
534
558
|
) => Promise<void>;
|
|
535
559
|
```
|
|
536
560
|
|
|
561
|
+
---
|
|
562
|
+
|
|
537
563
|
### `ConduitEvents`
|
|
538
564
|
|
|
539
|
-
|
|
565
|
+
Full event map is defined in `src/types.ts`.
|