@theophilusdev/conduit 1.0.2 → 1.1.3
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 +7 -4
- package/dist/index.cjs +285 -42
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.mjs +285 -42
- package/dist/index.mjs.map +1 -1
- package/docs/DOCS.md +47 -14
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -58,7 +58,24 @@ var ConduitMessagesAPI = class {
|
|
|
58
58
|
* @param threadID - The target thread ID.
|
|
59
59
|
*/
|
|
60
60
|
send(body, threadID) {
|
|
61
|
-
|
|
61
|
+
if (typeof body === "string") {
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
|
+
this.bot.ctx.api.sendMessage(
|
|
64
|
+
{ body },
|
|
65
|
+
threadID,
|
|
66
|
+
(err, data) => {
|
|
67
|
+
if (err) reject(err);
|
|
68
|
+
else resolve(data);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return new Promise((resolve, reject) => {
|
|
74
|
+
this.bot.ctx.api.sendMessage(body, threadID, (err, data) => {
|
|
75
|
+
if (err) reject(err);
|
|
76
|
+
else resolve(data);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
62
79
|
}
|
|
63
80
|
/**
|
|
64
81
|
* Sends a quoted reply to a specific message.
|
|
@@ -67,12 +84,30 @@ var ConduitMessagesAPI = class {
|
|
|
67
84
|
* @param messageID - The message ID to reply to.
|
|
68
85
|
*/
|
|
69
86
|
reply(body, threadID, messageID) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
if (typeof body === "string") {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
this.bot.ctx.api.sendMessage(
|
|
90
|
+
{ body },
|
|
91
|
+
threadID,
|
|
92
|
+
(err, data) => {
|
|
93
|
+
if (err) reject(err);
|
|
94
|
+
else resolve(data);
|
|
95
|
+
},
|
|
96
|
+
messageID
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
this.bot.ctx.api.sendMessage(
|
|
102
|
+
body,
|
|
103
|
+
threadID,
|
|
104
|
+
(err, data) => {
|
|
105
|
+
if (err) reject(err);
|
|
106
|
+
else resolve(data);
|
|
107
|
+
},
|
|
108
|
+
messageID
|
|
109
|
+
);
|
|
110
|
+
});
|
|
76
111
|
}
|
|
77
112
|
/**
|
|
78
113
|
* Edits an existing message.
|
|
@@ -80,21 +115,36 @@ var ConduitMessagesAPI = class {
|
|
|
80
115
|
* @param body - The new message text.
|
|
81
116
|
*/
|
|
82
117
|
edit(messageID, body) {
|
|
83
|
-
return
|
|
118
|
+
return new Promise((resolve, reject) => {
|
|
119
|
+
this.bot.ctx.api.editMessage(body, messageID, (err, data) => {
|
|
120
|
+
if (err) reject(err);
|
|
121
|
+
else resolve(data);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
84
124
|
}
|
|
85
125
|
/**
|
|
86
126
|
* Unsends (retracts) a message sent by the bot.
|
|
87
127
|
* @param messageID - The message ID to unsend.
|
|
88
128
|
*/
|
|
89
129
|
unsend(messageID) {
|
|
90
|
-
return
|
|
130
|
+
return new Promise((resolve, reject) => {
|
|
131
|
+
this.bot.ctx.api.unsendMessage(messageID, (err) => {
|
|
132
|
+
if (err) reject(err);
|
|
133
|
+
else resolve(null);
|
|
134
|
+
});
|
|
135
|
+
});
|
|
91
136
|
}
|
|
92
137
|
/**
|
|
93
138
|
* Deletes a message.
|
|
94
139
|
* @param messageID - The message ID to delete.
|
|
95
140
|
*/
|
|
96
141
|
delete(messageID) {
|
|
97
|
-
return
|
|
142
|
+
return new Promise((resolve, reject) => {
|
|
143
|
+
this.bot.ctx.api.deleteMessage(messageID, (err) => {
|
|
144
|
+
if (err) reject(err);
|
|
145
|
+
else resolve(null);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
98
148
|
}
|
|
99
149
|
/**
|
|
100
150
|
* Adds or removes a reaction on a message.
|
|
@@ -103,28 +153,53 @@ var ConduitMessagesAPI = class {
|
|
|
103
153
|
* @param threadID - The thread the message belongs to.
|
|
104
154
|
*/
|
|
105
155
|
react(emoji, messageID, threadID) {
|
|
106
|
-
return
|
|
156
|
+
return new Promise((resolve, reject) => {
|
|
157
|
+
this.bot.ctx.api.setMessageReaction(
|
|
158
|
+
emoji,
|
|
159
|
+
messageID,
|
|
160
|
+
(err) => {
|
|
161
|
+
if (err) reject(err);
|
|
162
|
+
else resolve(null);
|
|
163
|
+
},
|
|
164
|
+
threadID
|
|
165
|
+
);
|
|
166
|
+
});
|
|
107
167
|
}
|
|
108
168
|
/**
|
|
109
169
|
* Sends a typing indicator to a thread.
|
|
110
170
|
* @param threadID - The target thread ID.
|
|
111
171
|
*/
|
|
112
172
|
sendTypingIndicator(threadID) {
|
|
113
|
-
return
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
this.bot.ctx.api.sendTypingIndicator(threadID, (err) => {
|
|
175
|
+
if (err) reject(err);
|
|
176
|
+
else resolve(null);
|
|
177
|
+
});
|
|
178
|
+
});
|
|
114
179
|
}
|
|
115
180
|
/**
|
|
116
181
|
* Marks a message as read.
|
|
117
182
|
* @param messageID - The message ID to mark as read.
|
|
118
183
|
*/
|
|
119
184
|
markAsRead(messageID) {
|
|
120
|
-
return
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
this.bot.ctx.api.markAsRead(messageID, (err) => {
|
|
187
|
+
if (err) reject(err);
|
|
188
|
+
else resolve(null);
|
|
189
|
+
});
|
|
190
|
+
});
|
|
121
191
|
}
|
|
122
192
|
/**
|
|
123
193
|
* Uploads a file attachment and returns an attachment object.
|
|
124
194
|
* @param file - A readable stream or file buffer.
|
|
125
195
|
*/
|
|
126
196
|
uploadAttachment(file) {
|
|
127
|
-
return
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
this.bot.ctx.api.uploadAttachment(file, (err, data) => {
|
|
199
|
+
if (err) reject(err);
|
|
200
|
+
else resolve(data);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
128
203
|
}
|
|
129
204
|
/**
|
|
130
205
|
* Forwards an existing attachment to another thread.
|
|
@@ -132,7 +207,12 @@ var ConduitMessagesAPI = class {
|
|
|
132
207
|
* @param threadID - The target thread ID.
|
|
133
208
|
*/
|
|
134
209
|
forwardAttachment(attachmentID, threadID) {
|
|
135
|
-
return
|
|
210
|
+
return new Promise((resolve, reject) => {
|
|
211
|
+
this.bot.ctx.api.forwardAttachment(attachmentID, threadID, (err) => {
|
|
212
|
+
if (err) reject(err);
|
|
213
|
+
else resolve(null);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
136
216
|
}
|
|
137
217
|
/**
|
|
138
218
|
* Shares a contact card to a thread.
|
|
@@ -140,7 +220,12 @@ var ConduitMessagesAPI = class {
|
|
|
140
220
|
* @param threadID - The target thread ID.
|
|
141
221
|
*/
|
|
142
222
|
shareContact(userID, threadID) {
|
|
143
|
-
return
|
|
223
|
+
return new Promise((resolve, reject) => {
|
|
224
|
+
this.bot.ctx.api.shareContact(userID, threadID, (err, data) => {
|
|
225
|
+
if (err) reject(err);
|
|
226
|
+
else resolve(data);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
144
229
|
}
|
|
145
230
|
/**
|
|
146
231
|
* Changes the color theme of a thread.
|
|
@@ -148,7 +233,12 @@ var ConduitMessagesAPI = class {
|
|
|
148
233
|
* @param threadID - The target thread ID.
|
|
149
234
|
*/
|
|
150
235
|
changeThreadColor(color, threadID) {
|
|
151
|
-
return
|
|
236
|
+
return new Promise((resolve, reject) => {
|
|
237
|
+
this.bot.ctx.api.changeThreadColor(color, threadID, (err) => {
|
|
238
|
+
if (err) reject(err);
|
|
239
|
+
else resolve(null);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
152
242
|
}
|
|
153
243
|
/**
|
|
154
244
|
* Changes the quick-reaction emoji of a thread.
|
|
@@ -156,20 +246,35 @@ var ConduitMessagesAPI = class {
|
|
|
156
246
|
* @param threadID - The target thread ID.
|
|
157
247
|
*/
|
|
158
248
|
changeThreadEmoji(emoji, threadID) {
|
|
159
|
-
return
|
|
249
|
+
return new Promise((resolve, reject) => {
|
|
250
|
+
this.bot.ctx.api.changeThreadEmoji(emoji, threadID, (err) => {
|
|
251
|
+
if (err) reject(err);
|
|
252
|
+
else resolve(null);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
160
255
|
}
|
|
161
256
|
/**
|
|
162
257
|
* Fetches a specific message by ID.
|
|
163
258
|
* @param messageID - The message ID to fetch.
|
|
164
259
|
*/
|
|
165
260
|
getMessage(messageID) {
|
|
166
|
-
return
|
|
261
|
+
return new Promise((resolve, reject) => {
|
|
262
|
+
this.bot.ctx.api.getMessage(messageID, (err, data) => {
|
|
263
|
+
if (err) reject(err);
|
|
264
|
+
else resolve(data);
|
|
265
|
+
});
|
|
266
|
+
});
|
|
167
267
|
}
|
|
168
268
|
/**
|
|
169
269
|
* Returns all available thread color themes.
|
|
170
270
|
*/
|
|
171
271
|
getThreadColors() {
|
|
172
|
-
return
|
|
272
|
+
return new Promise((resolve, reject) => {
|
|
273
|
+
this.bot.ctx.api.getThreadColors((err, data) => {
|
|
274
|
+
if (err) reject(err);
|
|
275
|
+
else resolve(data);
|
|
276
|
+
});
|
|
277
|
+
});
|
|
173
278
|
}
|
|
174
279
|
};
|
|
175
280
|
|
|
@@ -184,7 +289,12 @@ var ConduitThreadsAPI = class {
|
|
|
184
289
|
* @param threadID - The thread ID to query.
|
|
185
290
|
*/
|
|
186
291
|
getInfo(threadID) {
|
|
187
|
-
return
|
|
292
|
+
return new Promise((resolve, reject) => {
|
|
293
|
+
this.bot.ctx.api.getThreadInfo(threadID, (err, data) => {
|
|
294
|
+
if (err) reject(err);
|
|
295
|
+
else resolve(data);
|
|
296
|
+
});
|
|
297
|
+
});
|
|
188
298
|
}
|
|
189
299
|
/**
|
|
190
300
|
* Fetches a paginated list of threads.
|
|
@@ -193,7 +303,17 @@ var ConduitThreadsAPI = class {
|
|
|
193
303
|
* @param folders - Folder filters e.g. `["INBOX"]`.
|
|
194
304
|
*/
|
|
195
305
|
getList(limit, cursor, folders) {
|
|
196
|
-
return
|
|
306
|
+
return new Promise((resolve, reject) => {
|
|
307
|
+
this.bot.ctx.api.getThreadList(
|
|
308
|
+
limit,
|
|
309
|
+
cursor,
|
|
310
|
+
folders,
|
|
311
|
+
(err, data) => {
|
|
312
|
+
if (err) reject(err);
|
|
313
|
+
else resolve(data);
|
|
314
|
+
}
|
|
315
|
+
);
|
|
316
|
+
});
|
|
197
317
|
}
|
|
198
318
|
/**
|
|
199
319
|
* Fetches message history for a thread.
|
|
@@ -201,14 +321,29 @@ var ConduitThreadsAPI = class {
|
|
|
201
321
|
* @param limit - Number of messages to return.
|
|
202
322
|
*/
|
|
203
323
|
getHistory(threadID, limit) {
|
|
204
|
-
return
|
|
324
|
+
return new Promise((resolve, reject) => {
|
|
325
|
+
this.bot.ctx.api.getThreadHistory(
|
|
326
|
+
threadID,
|
|
327
|
+
limit,
|
|
328
|
+
void 0,
|
|
329
|
+
(err, data) => {
|
|
330
|
+
if (err) reject(err);
|
|
331
|
+
else resolve(data);
|
|
332
|
+
}
|
|
333
|
+
);
|
|
334
|
+
});
|
|
205
335
|
}
|
|
206
336
|
/**
|
|
207
337
|
* Searches for threads by name or keyword.
|
|
208
338
|
* @param query - The search query string.
|
|
209
339
|
*/
|
|
210
340
|
search(query) {
|
|
211
|
-
return
|
|
341
|
+
return new Promise((resolve, reject) => {
|
|
342
|
+
this.bot.ctx.api.searchForThread(query, (err, data) => {
|
|
343
|
+
if (err) reject(err);
|
|
344
|
+
else resolve(data);
|
|
345
|
+
});
|
|
346
|
+
});
|
|
212
347
|
}
|
|
213
348
|
/**
|
|
214
349
|
* Creates a new group conversation.
|
|
@@ -216,7 +351,12 @@ var ConduitThreadsAPI = class {
|
|
|
216
351
|
* @param name - Optional group name.
|
|
217
352
|
*/
|
|
218
353
|
createGroup(userIDs, name) {
|
|
219
|
-
return
|
|
354
|
+
return new Promise((resolve, reject) => {
|
|
355
|
+
this.bot.ctx.api.createNewGroup(userIDs, name, (err, data) => {
|
|
356
|
+
if (err) reject(err);
|
|
357
|
+
else resolve(data);
|
|
358
|
+
});
|
|
359
|
+
});
|
|
220
360
|
}
|
|
221
361
|
/**
|
|
222
362
|
* Adds a user to an existing group thread.
|
|
@@ -224,7 +364,12 @@ var ConduitThreadsAPI = class {
|
|
|
224
364
|
* @param threadID - The target group thread ID.
|
|
225
365
|
*/
|
|
226
366
|
addUser(userID, threadID) {
|
|
227
|
-
return
|
|
367
|
+
return new Promise((resolve, reject) => {
|
|
368
|
+
this.bot.ctx.api.addUserToGroup(userID, threadID, (err) => {
|
|
369
|
+
if (err) reject(err);
|
|
370
|
+
else resolve(null);
|
|
371
|
+
});
|
|
372
|
+
});
|
|
228
373
|
}
|
|
229
374
|
/**
|
|
230
375
|
* Removes a user from a group thread.
|
|
@@ -232,7 +377,12 @@ var ConduitThreadsAPI = class {
|
|
|
232
377
|
* @param threadID - The target group thread ID.
|
|
233
378
|
*/
|
|
234
379
|
removeUser(userID, threadID) {
|
|
235
|
-
return
|
|
380
|
+
return new Promise((resolve, reject) => {
|
|
381
|
+
this.bot.ctx.api.removeUserFromGroup(userID, threadID, (err) => {
|
|
382
|
+
if (err) reject(err);
|
|
383
|
+
else resolve(null);
|
|
384
|
+
});
|
|
385
|
+
});
|
|
236
386
|
}
|
|
237
387
|
/**
|
|
238
388
|
* Promotes or demotes a user's admin status in a group.
|
|
@@ -241,7 +391,17 @@ var ConduitThreadsAPI = class {
|
|
|
241
391
|
* @param admin - `true` to promote, `false` to demote.
|
|
242
392
|
*/
|
|
243
393
|
changeAdminStatus(userID, threadID, admin) {
|
|
244
|
-
return
|
|
394
|
+
return new Promise((resolve, reject) => {
|
|
395
|
+
this.bot.ctx.api.changeAdminStatus(
|
|
396
|
+
userID,
|
|
397
|
+
threadID,
|
|
398
|
+
admin,
|
|
399
|
+
(err) => {
|
|
400
|
+
if (err) reject(err);
|
|
401
|
+
else resolve(null);
|
|
402
|
+
}
|
|
403
|
+
);
|
|
404
|
+
});
|
|
245
405
|
}
|
|
246
406
|
/**
|
|
247
407
|
* Updates the group's profile image.
|
|
@@ -249,7 +409,12 @@ var ConduitThreadsAPI = class {
|
|
|
249
409
|
* @param threadID - The target group thread ID.
|
|
250
410
|
*/
|
|
251
411
|
changeGroupImage(image, threadID) {
|
|
252
|
-
return
|
|
412
|
+
return new Promise((resolve, reject) => {
|
|
413
|
+
this.bot.ctx.api.changeGroupImage(image, threadID, (err) => {
|
|
414
|
+
if (err) reject(err);
|
|
415
|
+
else resolve(null);
|
|
416
|
+
});
|
|
417
|
+
});
|
|
253
418
|
}
|
|
254
419
|
/**
|
|
255
420
|
* Sets a participant's nickname in a thread.
|
|
@@ -258,7 +423,17 @@ var ConduitThreadsAPI = class {
|
|
|
258
423
|
* @param userID - The target user ID.
|
|
259
424
|
*/
|
|
260
425
|
changeNickname(nickname, threadID, userID) {
|
|
261
|
-
return
|
|
426
|
+
return new Promise((resolve, reject) => {
|
|
427
|
+
this.bot.ctx.api.changeNickname(
|
|
428
|
+
nickname,
|
|
429
|
+
threadID,
|
|
430
|
+
userID,
|
|
431
|
+
(err) => {
|
|
432
|
+
if (err) reject(err);
|
|
433
|
+
else resolve(null);
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
});
|
|
262
437
|
}
|
|
263
438
|
/**
|
|
264
439
|
* Changes the title of a group thread.
|
|
@@ -266,7 +441,12 @@ var ConduitThreadsAPI = class {
|
|
|
266
441
|
* @param threadID - The target group thread ID.
|
|
267
442
|
*/
|
|
268
443
|
setTitle(title, threadID) {
|
|
269
|
-
return
|
|
444
|
+
return new Promise((resolve, reject) => {
|
|
445
|
+
this.bot.ctx.api.setTitle(title, threadID, (err) => {
|
|
446
|
+
if (err) reject(err);
|
|
447
|
+
else resolve(null);
|
|
448
|
+
});
|
|
449
|
+
});
|
|
270
450
|
}
|
|
271
451
|
/**
|
|
272
452
|
* Creates a poll in a thread.
|
|
@@ -275,14 +455,29 @@ var ConduitThreadsAPI = class {
|
|
|
275
455
|
* @param options - Array of answer options.
|
|
276
456
|
*/
|
|
277
457
|
createPoll(title, threadID, options) {
|
|
278
|
-
return
|
|
458
|
+
return new Promise((resolve, reject) => {
|
|
459
|
+
this.bot.ctx.api.createPoll(
|
|
460
|
+
title,
|
|
461
|
+
threadID,
|
|
462
|
+
options,
|
|
463
|
+
(err, data) => {
|
|
464
|
+
if (err) reject(err);
|
|
465
|
+
else resolve(data);
|
|
466
|
+
}
|
|
467
|
+
);
|
|
468
|
+
});
|
|
279
469
|
}
|
|
280
470
|
/**
|
|
281
471
|
* Deletes a thread.
|
|
282
472
|
* @param threadID - The thread ID to delete.
|
|
283
473
|
*/
|
|
284
474
|
delete(threadID) {
|
|
285
|
-
return
|
|
475
|
+
return new Promise((resolve, reject) => {
|
|
476
|
+
this.bot.ctx.api.deleteThread(threadID, (err) => {
|
|
477
|
+
if (err) reject(err);
|
|
478
|
+
else resolve(null);
|
|
479
|
+
});
|
|
480
|
+
});
|
|
286
481
|
}
|
|
287
482
|
/**
|
|
288
483
|
* Mutes or unmutes notifications for a thread.
|
|
@@ -290,7 +485,12 @@ var ConduitThreadsAPI = class {
|
|
|
290
485
|
* @param muteUntil - Timestamp (ms) to mute until. Pass `-1` to mute indefinitely, `0` to unmute.
|
|
291
486
|
*/
|
|
292
487
|
mute(threadID, muteUntil) {
|
|
293
|
-
return
|
|
488
|
+
return new Promise((resolve, reject) => {
|
|
489
|
+
this.bot.ctx.api.muteThread(threadID, muteUntil, (err) => {
|
|
490
|
+
if (err) reject(err);
|
|
491
|
+
else resolve(null);
|
|
492
|
+
});
|
|
493
|
+
});
|
|
294
494
|
}
|
|
295
495
|
/**
|
|
296
496
|
* Accepts or declines a message request.
|
|
@@ -298,7 +498,12 @@ var ConduitThreadsAPI = class {
|
|
|
298
498
|
* @param accept - `true` to accept, `false` to decline.
|
|
299
499
|
*/
|
|
300
500
|
handleMessageRequest(threadID, accept) {
|
|
301
|
-
return
|
|
501
|
+
return new Promise((resolve, reject) => {
|
|
502
|
+
this.bot.ctx.api.handleMessageRequest(threadID, accept, (err) => {
|
|
503
|
+
if (err) reject(err);
|
|
504
|
+
else resolve(null);
|
|
505
|
+
});
|
|
506
|
+
});
|
|
302
507
|
}
|
|
303
508
|
};
|
|
304
509
|
|
|
@@ -313,20 +518,38 @@ var ConduitUsersAPI = class {
|
|
|
313
518
|
* @param userID - A single user ID or an array of user IDs.
|
|
314
519
|
*/
|
|
315
520
|
getInfo(userID) {
|
|
316
|
-
return
|
|
521
|
+
return new Promise((resolve, reject) => {
|
|
522
|
+
this.bot.ctx.api.getUserInfo(
|
|
523
|
+
Array.isArray(userID) ? userID : [userID],
|
|
524
|
+
(err, data) => {
|
|
525
|
+
if (err) reject(err);
|
|
526
|
+
else resolve(data);
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
});
|
|
317
530
|
}
|
|
318
531
|
/**
|
|
319
532
|
* Resolves a vanity URL or username to a Facebook user ID.
|
|
320
533
|
* @param vanity - The vanity name or profile URL slug.
|
|
321
534
|
*/
|
|
322
535
|
getID(vanity) {
|
|
323
|
-
return
|
|
536
|
+
return new Promise((resolve, reject) => {
|
|
537
|
+
this.bot.ctx.api.getUserID(vanity, (err, data) => {
|
|
538
|
+
if (err) reject(err);
|
|
539
|
+
else resolve(data);
|
|
540
|
+
});
|
|
541
|
+
});
|
|
324
542
|
}
|
|
325
543
|
/**
|
|
326
544
|
* Returns the authenticated user's friends list.
|
|
327
545
|
*/
|
|
328
546
|
getFriendsList() {
|
|
329
|
-
return
|
|
547
|
+
return new Promise((resolve, reject) => {
|
|
548
|
+
this.bot.ctx.api.getFriendsList((err, data) => {
|
|
549
|
+
if (err) reject(err);
|
|
550
|
+
else resolve(data);
|
|
551
|
+
});
|
|
552
|
+
});
|
|
330
553
|
}
|
|
331
554
|
};
|
|
332
555
|
|
|
@@ -348,7 +571,12 @@ var ConduitAccountAPI = class {
|
|
|
348
571
|
* @param block - `true` to block, `false` to unblock.
|
|
349
572
|
*/
|
|
350
573
|
blockUser(userID, block) {
|
|
351
|
-
return
|
|
574
|
+
return new Promise((resolve, reject) => {
|
|
575
|
+
this.bot.ctx.api.changeBlockedStatus(userID, block, (err) => {
|
|
576
|
+
if (err) reject(err);
|
|
577
|
+
else resolve(null);
|
|
578
|
+
});
|
|
579
|
+
});
|
|
352
580
|
}
|
|
353
581
|
/**
|
|
354
582
|
* Accepts or declines a friend request.
|
|
@@ -356,20 +584,35 @@ var ConduitAccountAPI = class {
|
|
|
356
584
|
* @param accept - `true` to accept, `false` to decline.
|
|
357
585
|
*/
|
|
358
586
|
handleFriendRequest(userID, accept) {
|
|
359
|
-
return
|
|
587
|
+
return new Promise((resolve, reject) => {
|
|
588
|
+
this.bot.ctx.api.handleFriendRequest(userID, accept, (err) => {
|
|
589
|
+
if (err) reject(err);
|
|
590
|
+
else resolve(null);
|
|
591
|
+
});
|
|
592
|
+
});
|
|
360
593
|
}
|
|
361
594
|
/**
|
|
362
595
|
* Removes a user from the friends list.
|
|
363
596
|
* @param userID - The target user ID.
|
|
364
597
|
*/
|
|
365
598
|
unfriend(userID) {
|
|
366
|
-
return
|
|
599
|
+
return new Promise((resolve, reject) => {
|
|
600
|
+
this.bot.ctx.api.unfriend(userID, (err) => {
|
|
601
|
+
if (err) reject(err);
|
|
602
|
+
else resolve(null);
|
|
603
|
+
});
|
|
604
|
+
});
|
|
367
605
|
}
|
|
368
606
|
/**
|
|
369
607
|
* Ends the current session and invalidates cookies.
|
|
370
608
|
*/
|
|
371
609
|
logout() {
|
|
372
|
-
return
|
|
610
|
+
return new Promise((resolve, reject) => {
|
|
611
|
+
this.bot.ctx.api.logout((err) => {
|
|
612
|
+
if (err) reject(err);
|
|
613
|
+
else resolve(null);
|
|
614
|
+
});
|
|
615
|
+
});
|
|
373
616
|
}
|
|
374
617
|
};
|
|
375
618
|
|