@alemonjs/qq-bot 2.1.0-alpha.16 → 2.1.0-alpha.18

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/lib/sdk/api.js CHANGED
@@ -2,6 +2,7 @@ import axios from 'axios';
2
2
  import { config } from './config.js';
3
3
  import FormData from 'form-data';
4
4
  import { createPicFrom } from 'alemonjs/utils';
5
+ import { createAxiosInstance } from './instance.js';
5
6
 
6
7
  const BOTS_API_RUL = 'https://bots.qq.com';
7
8
  const API_URL_SANDBOX = 'https://sandbox.api.sgroup.qq.com';
@@ -35,10 +36,10 @@ class QQBotAPI {
35
36
  timeout: 20000,
36
37
  headers: {
37
38
  'X-Union-Appid': app_id,
38
- 'Authorization': `QQBot ${token}`
39
+ Authorization: `QQBot ${token}`
39
40
  }
40
41
  });
41
- return service(options);
42
+ return createAxiosInstance(service, options);
42
43
  }
43
44
  /**
44
45
  * guild
@@ -56,29 +57,29 @@ class QQBotAPI {
56
57
  Authorization: `Bot ${app_id}.${token}`
57
58
  }
58
59
  });
59
- return service(opstion);
60
+ return createAxiosInstance(service, opstion);
60
61
  }
61
62
  /**
62
63
  * 得到鉴权
63
64
  * @returns
64
65
  */
65
- async gateway() {
66
+ gateway() {
66
67
  const mode = config.get('mode');
67
68
  if (mode === 'group') {
68
69
  return this.groupService({
69
70
  url: '/gateway'
70
- }).then(res => res?.data);
71
+ });
71
72
  }
72
73
  else if (mode === 'guild') {
73
74
  return this.guildServer({
74
75
  url: '/gateway'
75
- }).then(res => res?.data);
76
+ });
76
77
  }
77
78
  else {
78
79
  // 默认group
79
80
  return this.groupService({
80
81
  url: '/gateway'
81
- }).then(res => res?.data);
82
+ });
82
83
  }
83
84
  }
84
85
  /**
@@ -89,7 +90,7 @@ class QQBotAPI {
89
90
  * @returns
90
91
  * 0 文本 1 图文 2 md 3 ark 4 embed
91
92
  */
92
- async usersOpenMessages(openid, data) {
93
+ usersOpenMessages(openid, data) {
93
94
  const db = {
94
95
  ...(data.event_id
95
96
  ? { event_id: data.event_id }
@@ -102,7 +103,7 @@ class QQBotAPI {
102
103
  url: `/v2/users/${openid}/messages`,
103
104
  method: 'post',
104
105
  data: db
105
- }).then(res => res?.data);
106
+ });
106
107
  }
107
108
  /**
108
109
  * 得到消息序列
@@ -116,8 +117,9 @@ class QQBotAPI {
116
117
  // 如果映射表大小超过 100,则删除最早添加的 MessageId
117
118
  if (msgMap.size > 100) {
118
119
  const firstKey = msgMap.keys().next().value;
119
- if (firstKey)
120
+ if (firstKey) {
120
121
  msgMap.delete(firstKey);
122
+ }
121
123
  }
122
124
  return seq;
123
125
  }
@@ -127,7 +129,7 @@ class QQBotAPI {
127
129
  * @param data
128
130
  * @returns
129
131
  */
130
- async groupOpenMessages(group_openid, data) {
132
+ groupOpenMessages(group_openid, data) {
131
133
  const db = {
132
134
  ...(data.event_id
133
135
  ? { event_id: data.event_id }
@@ -140,22 +142,7 @@ class QQBotAPI {
140
142
  url: `/v2/groups/${group_openid}/messages`,
141
143
  method: 'post',
142
144
  data: db
143
- }).then(res => res?.data);
144
- }
145
- /**
146
- * 发送私聊富媒体文件
147
- * @param openid
148
- * @param data
149
- * @returns
150
- * 1 图文 2 视频 3 语言 4 文件
151
- * 图片:png/jpg,视频:mp4,语音:silk
152
- */
153
- async postRichMediaByUsers(openid, data) {
154
- return this.groupService({
155
- url: `/v2/users/${openid}/files`,
156
- method: 'post',
157
- data: data
158
- }).then(res => res?.data);
145
+ });
159
146
  }
160
147
  /**
161
148
  * 发送私聊富媒体文件
@@ -165,38 +152,22 @@ class QQBotAPI {
165
152
  * 1 图文 2 视频 3 语言 4 文件
166
153
  * 图片:png/jpg,视频:mp4,语音:silk
167
154
  */
168
- async userFiles(openid, data) {
155
+ postRichMediaByUser(openid, data) {
169
156
  return this.groupService({
170
157
  url: `/v2/users/${openid}/files`,
171
158
  method: 'post',
172
159
  data: data
173
- }).then(res => res?.data);
160
+ });
174
161
  }
175
162
  /**
176
163
  * 发送群里文件
177
- * @param openid GuildID / UserId
164
+ * @param openid
178
165
  * @param data
179
166
  * @returns
180
167
  * 1 图文 2 视频 3 语言 4 文件
181
168
  * 图片:png/jpg,视频:mp4,语音:silk
182
169
  */
183
- async postRichMediaById(openid, data) {
184
- return this.groupService({
185
- url: `/v2/groups/${openid}/files`,
186
- method: 'post',
187
- data: {
188
- srv_send_msg: false,
189
- ...data
190
- }
191
- }).then(res => res?.data);
192
- }
193
- /**
194
- *
195
- * @param openid
196
- * @param data
197
- * @returns
198
- */
199
- async groupsFiles(openid, data) {
170
+ postRichMediaByGroup(openid, data) {
200
171
  return this.groupService({
201
172
  url: `/v2/groups/${openid}/files`,
202
173
  method: 'post',
@@ -204,7 +175,7 @@ class QQBotAPI {
204
175
  srv_send_msg: false,
205
176
  ...data
206
177
  }
207
- }).then(res => res?.data);
178
+ });
208
179
  }
209
180
  /**
210
181
  *
@@ -212,11 +183,11 @@ class QQBotAPI {
212
183
  * @param message_id
213
184
  * @returns
214
185
  */
215
- async userMessageDelete(openid, message_id) {
186
+ userMessageDelete(openid, message_id) {
216
187
  return this.groupService({
217
188
  url: `/v2/users/${openid}/messages/${message_id}`,
218
189
  method: 'delete'
219
- }).then(res => res?.data);
190
+ });
220
191
  }
221
192
  /**
222
193
  *
@@ -224,11 +195,11 @@ class QQBotAPI {
224
195
  * @param message_id
225
196
  * @returns
226
197
  */
227
- async grouMessageDelte(group_openid, message_id) {
198
+ grouMessageDelte(group_openid, message_id) {
228
199
  return this.groupService({
229
200
  url: `/v2/groups/${group_openid}/messages/${message_id}`,
230
201
  method: 'delete'
231
- }).then(res => res?.data);
202
+ });
232
203
  }
233
204
  /**
234
205
  * ************
@@ -264,7 +235,7 @@ class QQBotAPI {
264
235
  'Content-Type': `multipart/form-data; boundary=${dary}`
265
236
  },
266
237
  data: formdata
267
- }).then(res => res?.data);
238
+ });
268
239
  }
269
240
  /**
270
241
  * 私聊发送
@@ -294,7 +265,7 @@ class QQBotAPI {
294
265
  'Content-Type': `multipart/form-data; boundary=${dary}`
295
266
  },
296
267
  data: formdata
297
- }).then(res => res?.data);
268
+ });
298
269
  }
299
270
  /**
300
271
  * ********
@@ -306,23 +277,23 @@ class QQBotAPI {
306
277
  * @param message
307
278
  * @returns
308
279
  */
309
- async usersMe() {
280
+ usersMe() {
310
281
  return this.guildServer({
311
282
  method: 'get',
312
- url: `/users/@me`
313
- }).then(res => res?.data);
283
+ url: '/users/@me'
284
+ });
314
285
  }
315
286
  /**
316
287
  * 获取用户频道列表
317
288
  * @param message
318
289
  * @returns
319
290
  */
320
- async usersMeGuilds(params) {
291
+ usersMeGuilds(params) {
321
292
  return this.guildServer({
322
293
  method: 'get',
323
- url: `/users/@me/guilds`,
294
+ url: '/users/@me/guilds',
324
295
  params
325
- }).then(res => res?.data);
296
+ });
326
297
  }
327
298
  /**
328
299
  * **********
@@ -334,11 +305,11 @@ class QQBotAPI {
334
305
  * @param guild_id
335
306
  * @returns
336
307
  */
337
- async guilds(guild_id) {
308
+ guilds(guild_id) {
338
309
  return this.guildServer({
339
310
  method: 'get',
340
311
  url: `/guilds/${guild_id}`
341
- }).then(res => res?.data);
312
+ });
342
313
  }
343
314
  /**
344
315
  * ************
@@ -350,46 +321,46 @@ class QQBotAPI {
350
321
  * @param guild_id
351
322
  * @returns
352
323
  */
353
- async guildsChannels(guild_id) {
324
+ guildsChannels(guild_id) {
354
325
  return this.guildServer({
355
326
  method: 'get',
356
327
  url: `/guilds/${guild_id}/channels`
357
- }).then(res => res?.data);
328
+ });
358
329
  }
359
330
  /**
360
331
  * 获取子频道详情
361
332
  * @param channel_id
362
333
  * @returns
363
334
  */
364
- async channels(channel_id) {
335
+ channels(channel_id) {
365
336
  return this.guildServer({
366
337
  method: 'get',
367
338
  url: `/channels/${channel_id}`
368
- }).then(res => res?.data);
339
+ });
369
340
  }
370
341
  /**
371
342
  * 创建子频道
372
343
  * @param guild_id
373
344
  * @returns
374
345
  */
375
- async guildsChannelsCreate(guild_id, data) {
346
+ guildsChannelsCreate(guild_id, data) {
376
347
  return this.guildServer({
377
348
  method: 'post',
378
349
  url: `/guilds/${guild_id}/channels`,
379
350
  data
380
- }).then(res => res?.data);
351
+ });
381
352
  }
382
353
  /**
383
354
  * 创建子频道
384
355
  * @param channel_id
385
356
  * @returns
386
357
  */
387
- async guildsChannelsUpdate(channel_id, data) {
358
+ guildsChannelsUpdate(channel_id, data) {
388
359
  return this.guildServer({
389
360
  method: 'PATCH',
390
361
  url: `/channels/${channel_id}`,
391
362
  data
392
- }).then(res => res?.data);
363
+ });
393
364
  }
394
365
  /**
395
366
  * 删除子频道
@@ -397,23 +368,23 @@ class QQBotAPI {
397
368
  * @param data
398
369
  * @returns
399
370
  */
400
- async guildsChannelsdelete(channel_id, data) {
371
+ guildsChannelsdelete(channel_id, data) {
401
372
  return this.guildServer({
402
373
  method: 'DELETE',
403
374
  url: `/channels/${channel_id}`,
404
375
  data
405
- }).then(res => res?.data);
376
+ });
406
377
  }
407
378
  /**
408
379
  * 获取在线成员数
409
380
  * @param channel_id
410
381
  * @returns
411
382
  */
412
- async channelsChannelOnlineNums(channel_id) {
383
+ channelsChannelOnlineNums(channel_id) {
413
384
  return this.guildServer({
414
385
  method: 'GET',
415
386
  url: `/channels/${channel_id}/online_nums`
416
- }).then(res => res?.data);
387
+ });
417
388
  }
418
389
  /**
419
390
  * *********
@@ -425,12 +396,12 @@ class QQBotAPI {
425
396
  * @param guild_id
426
397
  * @returns
427
398
  */
428
- async guildsMembers(guild_id, params) {
399
+ guildsMembers(guild_id, params) {
429
400
  return this.guildServer({
430
401
  method: 'GET',
431
402
  url: `/guilds/${guild_id}/members`,
432
403
  params
433
- }).then(res => res?.data);
404
+ });
434
405
  }
435
406
  /**
436
407
  * 获取频道身份组成员列表
@@ -439,12 +410,12 @@ class QQBotAPI {
439
410
  * @param params
440
411
  * @returns
441
412
  */
442
- async guildsRolesMembers(guild_id, role_id, params) {
413
+ guildsRolesMembers(guild_id, role_id, params) {
443
414
  return this.guildServer({
444
415
  method: 'GET',
445
416
  url: `/guilds/${guild_id}/roles/${role_id}/members`,
446
417
  params
447
- }).then(res => res?.data);
418
+ });
448
419
  }
449
420
  /**
450
421
  * 获取成员详情
@@ -452,11 +423,11 @@ class QQBotAPI {
452
423
  * @param user_id
453
424
  * @returns
454
425
  */
455
- async guildsMembersMessage(guild_id, user_id) {
426
+ guildsMembersMessage(guild_id, user_id) {
456
427
  return this.guildServer({
457
428
  method: 'GET',
458
429
  url: `/guilds/${guild_id}/members/${user_id}`
459
- }).then(res => res?.data);
430
+ });
460
431
  }
461
432
  /**
462
433
  * 删除频道成员
@@ -464,11 +435,11 @@ class QQBotAPI {
464
435
  * @param user_id
465
436
  * @returns
466
437
  */
467
- async guildsMembersDelete(guild_id, user_id) {
438
+ guildsMembersDelete(guild_id, user_id) {
468
439
  return this.guildServer({
469
440
  method: 'DELETE',
470
441
  url: `/guilds/${guild_id}/members/${user_id}`
471
- }).then(res => res?.data);
442
+ });
472
443
  }
473
444
  /**
474
445
  * 获取指定消息
@@ -476,11 +447,11 @@ class QQBotAPI {
476
447
  * @param message_id
477
448
  * @returns
478
449
  */
479
- async channelsMessagesById(channel_id, message_id) {
450
+ channelsMessagesById(channel_id, message_id) {
480
451
  return this.guildServer({
481
452
  method: 'GET',
482
453
  url: `/channels/${channel_id}/messages/${message_id}`
483
- }).then(res => res?.data);
454
+ });
484
455
  }
485
456
  /**
486
457
  * 撤回消息
@@ -489,11 +460,11 @@ class QQBotAPI {
489
460
  * @param hidetip
490
461
  * @returns
491
462
  */
492
- async channelsMessagesDelete(channel_id, message_id, hidetip = true) {
463
+ channelsMessagesDelete(channel_id, message_id, hidetip = true) {
493
464
  return this.guildServer({
494
465
  method: 'DELETE',
495
466
  url: `/channels/${channel_id}/messages/${message_id}?hidetip=${hidetip}`
496
- }).then(res => res?.data);
467
+ });
497
468
  }
498
469
  /**
499
470
  * ***********
@@ -505,11 +476,11 @@ class QQBotAPI {
505
476
  * @param guild_id 频道id
506
477
  * @returns
507
478
  */
508
- async guildsRoles(guild_id) {
479
+ guildsRoles(guild_id) {
509
480
  return this.guildServer({
510
481
  method: 'GET',
511
482
  url: `/guilds/${guild_id}/roles`
512
- }).then(res => res?.data);
483
+ });
513
484
  }
514
485
  /**
515
486
  * 创建频道身份组
@@ -520,12 +491,12 @@ class QQBotAPI {
520
491
  * @param {object?} data.hoist 在成员列表中单独展示: 0-否, 1-是
521
492
  * @returns
522
493
  */
523
- async guildsRolesPost(guild_id, data) {
494
+ guildsRolesPost(guild_id, data) {
524
495
  return this.guildServer({
525
496
  method: 'POST',
526
497
  url: `/guilds/${guild_id}/roles`,
527
498
  data
528
- }).then(res => res?.data);
499
+ });
529
500
  }
530
501
  /**
531
502
  * 修改频道身份组
@@ -536,23 +507,23 @@ class QQBotAPI {
536
507
  * @param {object?} data.hoist 在成员列表中单独展示: 0-否, 1-是
537
508
  * @returns
538
509
  */
539
- async guildsRolesPatch(guild_id, role_id, data) {
510
+ guildsRolesPatch(guild_id, role_id, data) {
540
511
  return this.guildServer({
541
512
  method: 'PATCH',
542
513
  url: `/guilds/${guild_id}/roles/${role_id}`,
543
514
  data
544
- }).then(res => res?.data);
515
+ });
545
516
  }
546
517
  /**
547
518
  * 删除频道身份组
548
519
  * @param guild_id 频道id
549
520
  * @param role_id 身份组id
550
521
  */
551
- async guildsRolesDelete(guild_id, role_id) {
522
+ guildsRolesDelete(guild_id, role_id) {
552
523
  return this.guildServer({
553
524
  method: 'DELETE',
554
525
  url: `/guilds/${guild_id}/roles/${role_id}`
555
- }).then(res => res?.data);
526
+ });
556
527
  }
557
528
  /**
558
529
  * 将成员添加到频道身份组
@@ -562,7 +533,7 @@ class QQBotAPI {
562
533
  * @param role_id 身份组id
563
534
  * @returns
564
535
  */
565
- async guildsRolesMembersPut(guild_id, channel_id, user_id, role_id) {
536
+ guildsRolesMembersPut(guild_id, channel_id, user_id, role_id) {
566
537
  return this.guildServer({
567
538
  method: 'PUT',
568
539
  url: `/guilds/${guild_id}/members/${user_id}/roles/${role_id}`,
@@ -571,7 +542,7 @@ class QQBotAPI {
571
542
  id: channel_id
572
543
  }
573
544
  }
574
- }).then(res => res?.data);
545
+ });
575
546
  }
576
547
  /**
577
548
  * 将成员从频道身份组移除
@@ -581,7 +552,7 @@ class QQBotAPI {
581
552
  * @param role_id 身份组id
582
553
  * @returns
583
554
  */
584
- async guildsRolesMembersDelete(guild_id, channel_id, user_id, role_id) {
555
+ guildsRolesMembersDelete(guild_id, channel_id, user_id, role_id) {
585
556
  return this.guildServer({
586
557
  method: 'DELETE',
587
558
  url: `/guilds/${guild_id}/members/${user_id}/roles/${role_id}`,
@@ -590,7 +561,7 @@ class QQBotAPI {
590
561
  id: channel_id
591
562
  }
592
563
  }
593
- }).then(res => res?.data);
564
+ });
594
565
  }
595
566
  /**
596
567
  * **********
@@ -602,11 +573,11 @@ class QQBotAPI {
602
573
  * @param channel_id 子频道id
603
574
  * @param user_id 用户id
604
575
  */
605
- async channelsPermissions(channel_id, user_id) {
576
+ channelsPermissions(channel_id, user_id) {
606
577
  return this.guildServer({
607
578
  method: 'GET',
608
579
  url: `/channels/${channel_id}/members/${user_id}/permissions`
609
- }).then(res => res?.data);
580
+ });
610
581
  }
611
582
  /**
612
583
  * 修改子频道用户权限
@@ -614,7 +585,7 @@ class QQBotAPI {
614
585
  * @param user_id 用户id
615
586
  * @param 参数包括add和remove两个字段分别表示授予的权限以及删除的权限。要授予用户权限即把add对应位置 1,删除用户权限即把remove对应位置 1。当两个字段同一位都为 1,表现为删除权限。
616
587
  */
617
- async channelsPermissionsPut(channel_id, user_id, add, remove) {
588
+ channelsPermissionsPut(channel_id, user_id, add, remove) {
618
589
  return this.guildServer({
619
590
  method: 'PUT',
620
591
  url: `/channels/${channel_id}/members/${user_id}/permissions`,
@@ -622,7 +593,7 @@ class QQBotAPI {
622
593
  add,
623
594
  remove
624
595
  }
625
- }).then(res => res?.data);
596
+ });
626
597
  }
627
598
  /**
628
599
  * *******
@@ -639,11 +610,11 @@ class QQBotAPI {
639
610
  * @param guild_id 频道id
640
611
  * @returns
641
612
  */
642
- async guildsMessageSetting(guild_id) {
613
+ guildsMessageSetting(guild_id) {
643
614
  return this.guildServer({
644
615
  method: 'GET',
645
616
  url: `/guilds/${guild_id}/message/setting`
646
- }).then(res => res?.data);
617
+ });
647
618
  }
648
619
  /**
649
620
  * ***********
@@ -656,11 +627,11 @@ class QQBotAPI {
656
627
  * @param source_guild_id 源频道 id
657
628
  * @returns
658
629
  */
659
- async usersMeDms() {
630
+ usersMeDms() {
660
631
  return this.guildServer({
661
632
  method: 'POST',
662
- url: `/users/@me/dms`
663
- }).then(res => res?.data);
633
+ url: '/users/@me/dms'
634
+ });
664
635
  }
665
636
  /**
666
637
  * 撤回私信
@@ -668,11 +639,11 @@ class QQBotAPI {
668
639
  * @param data
669
640
  * @returns
670
641
  */
671
- async dmsMessageDelete(guild_id, message_id, hidetip = true) {
642
+ dmsMessageDelete(guild_id, message_id, hidetip = true) {
672
643
  return this.guildServer({
673
644
  method: 'DELETE',
674
645
  url: `/dms/${guild_id}/messages/${message_id}?hidetip=${hidetip}`
675
- }).then(res => res?.data);
646
+ });
676
647
  }
677
648
  /**
678
649
  * *********
@@ -685,12 +656,12 @@ class QQBotAPI {
685
656
  * @param data { mute_end_timestamp:禁言结束时间戳, mute_seconds:禁言时长 } 两个参数必须传一个 优先级 mute_end_timestamp > mute_seconds
686
657
  * 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除全体禁言
687
658
  */
688
- async guildsMuteAll(guild_id, data) {
659
+ guildsMuteAll(guild_id, data) {
689
660
  return this.guildServer({
690
661
  method: 'PATCH',
691
662
  url: `/guilds/${guild_id}/mute`,
692
663
  data
693
- }).then(res => res?.data);
664
+ });
694
665
  }
695
666
  /**
696
667
  * 频道指定成员禁言
@@ -700,12 +671,12 @@ class QQBotAPI {
700
671
  * 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除禁言
701
672
  * @returns
702
673
  */
703
- async guildsMemberMute(guild_id, user_id, data) {
674
+ guildsMemberMute(guild_id, user_id, data) {
704
675
  return this.guildServer({
705
676
  method: 'PATCH',
706
677
  url: `/guilds/${guild_id}/members/${user_id}/mute`,
707
678
  data
708
- }).then(res => res?.data);
679
+ });
709
680
  }
710
681
  /**
711
682
  * 频道批量禁言
@@ -713,12 +684,12 @@ class QQBotAPI {
713
684
  * @param data { mute_end_timestamp:禁言结束时间戳, mute_seconds:禁言时长, user_ids:用户id数组 } 两个参数必须传一个 优先级 mute_end_timestamp > mute_seconds
714
685
  * 将mute_end_timestamp或mute_seconds传值为字符串'0',则表示解除禁言
715
686
  */
716
- async guildsMute(guild_id, data) {
687
+ guildsMute(guild_id, data) {
717
688
  return this.guildServer({
718
689
  method: 'PATCH',
719
690
  url: `/guilds/${guild_id}/mute`,
720
691
  data
721
- }).then(res => res?.data);
692
+ });
722
693
  }
723
694
  /**
724
695
  * *******
@@ -736,12 +707,12 @@ class QQBotAPI {
736
707
  * @param recommend_channels 推荐频道id数组 "recommend_channels": [{ "channel_id": "xxxx","introduce": "推荐语" }]
737
708
  * @returns 返回Announces 对象 (https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/announces/model.html#Announces)
738
709
  */
739
- async guildsAnnounces(guild_id, data) {
710
+ guildsAnnounces(guild_id, data) {
740
711
  return this.guildServer({
741
712
  method: 'POST',
742
713
  url: `/guilds/${guild_id}/announces`,
743
714
  data
744
- }).then(res => res?.data);
715
+ });
745
716
  }
746
717
  /**
747
718
  * 删除频道公告
@@ -749,11 +720,11 @@ class QQBotAPI {
749
720
  * @param message_id 消息id message_id 有值时,会校验 message_id 合法性,若不校验校验 message_id,请将 message_id 设置为 all
750
721
  * @returns
751
722
  */
752
- async guildsAnnouncesDelete(guild_id, message_id) {
723
+ guildsAnnouncesDelete(guild_id, message_id) {
753
724
  return this.guildServer({
754
725
  method: 'DELETE',
755
726
  url: `/guilds/${guild_id}/announces/${message_id}`
756
- }).then(res => res?.data);
727
+ });
757
728
  }
758
729
  /**
759
730
  * **********
@@ -767,11 +738,11 @@ class QQBotAPI {
767
738
  * @returns 返回 PinsMessage对象 { "guild_id": "xxxxxx", "channel_id": "xxxxxx", "message_ids": ["xxxxx"]}
768
739
  * @returns message_ids 为当前请求后子频道内所有精华消息 message_id 数组
769
740
  */
770
- async channelsPinsPut(channel_id, message_id) {
741
+ channelsPinsPut(channel_id, message_id) {
771
742
  return this.guildServer({
772
743
  method: 'PUT',
773
744
  url: `/channels/${channel_id}/pins/${message_id}`
774
- }).then(res => res?.data);
745
+ });
775
746
  }
776
747
  /**
777
748
  * 删除精华消息
@@ -780,11 +751,11 @@ class QQBotAPI {
780
751
  * 删除子频道内全部精华消息,请将 message_id 设置为 all
781
752
  * @returns
782
753
  */
783
- async channelsPinsDelete(channel_id, message_id) {
754
+ channelsPinsDelete(channel_id, message_id) {
784
755
  return this.guildServer({
785
756
  method: 'DELETE',
786
757
  url: `/channels/${channel_id}/pins/${message_id}`
787
- }).then(res => res?.data);
758
+ });
788
759
  }
789
760
  /**
790
761
  * 获取精华消息
@@ -792,11 +763,11 @@ class QQBotAPI {
792
763
  * @returns 返回 PinsMessage对象 { "guild_id": "xxxxxx", "channel_id": "xxxxxx", "message_ids": ["xxxxx"]}
793
764
  * @returns message_ids 为当前请求后子频道内所有精华消息 message_id 数组
794
765
  */
795
- async channelsPins(channel_id) {
766
+ channelsPins(channel_id) {
796
767
  return this.guildServer({
797
768
  method: 'GET',
798
769
  url: `/channels/${channel_id}/pins`
799
- }).then(res => res?.data);
770
+ });
800
771
  }
801
772
  /**
802
773
  * ********
@@ -808,11 +779,11 @@ class QQBotAPI {
808
779
  * @param channel_id 子频道id
809
780
  * @returns 返回 Schedule 对象数组(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
810
781
  */
811
- async channelsSchedules(channel_id) {
782
+ channelsSchedules(channel_id) {
812
783
  return this.guildServer({
813
784
  method: 'GET',
814
785
  url: `/channels/${channel_id}/schedules`
815
- }).then(res => res?.data);
786
+ });
816
787
  }
817
788
  /**
818
789
  * 获取频道日程详情
@@ -820,11 +791,11 @@ class QQBotAPI {
820
791
  * @param schedule_id 日程id
821
792
  * @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
822
793
  */
823
- async channelsSchedulesSchedule(channel_id, schedule_id) {
794
+ channelsSchedulesSchedule(channel_id, schedule_id) {
824
795
  return this.guildServer({
825
796
  method: 'GET',
826
797
  url: `/channels/${channel_id}/schedules/${schedule_id}`
827
- }).then(res => res?.data);
798
+ });
828
799
  }
829
800
  /**
830
801
  * 创建频道日程
@@ -835,20 +806,20 @@ class QQBotAPI {
835
806
  * @param end_timestamp 日程结束时间戳
836
807
  * @param jump_channel_id 日程开始时跳转的子频道id
837
808
  * @param remind_type 日程提醒类型
838
- * 0 不提醒
839
- * 1 开始时提醒
840
- * 2 开始前 5 分钟提醒
841
- * 3 开始前 15 分钟提醒
842
- * 4 开始前 30 分钟提醒
843
- * 5 开始前 60 分钟提醒
809
+ * 0不提醒
810
+ * 1开始时提醒
811
+ * 2开始前 5 分钟提醒
812
+ * 3开始前 15 分钟提醒
813
+ * 4开始前 30 分钟提醒
814
+ * 5开始前 60 分钟提醒
844
815
  * @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
845
816
  */
846
- async channelsSchedulesPost(channel_id, data) {
817
+ channelsSchedulesPost(channel_id, data) {
847
818
  return this.guildServer({
848
819
  method: 'POST',
849
820
  url: `/channels/${channel_id}/schedules`,
850
821
  data
851
- }).then(res => res?.data);
822
+ });
852
823
  }
853
824
  /**
854
825
  * 修改频道日程
@@ -860,20 +831,20 @@ class QQBotAPI {
860
831
  * @param end_timestamp 日程结束时间戳
861
832
  * @param jump_channel_id 日程开始时跳转的子频道id
862
833
  * @param remind_type 日程提醒类型
863
- * 0 不提醒
864
- * 1 开始时提醒
865
- * 2 开始前 5 分钟提醒
866
- * 3 开始前 15 分钟提醒
867
- * 4 开始前 30 分钟提醒
868
- * 5 开始前 60 分钟提醒
834
+ * 0不提醒
835
+ * 1开始时提醒
836
+ * 2开始前 5 分钟提醒
837
+ * 3开始前 15 分钟提醒
838
+ * 4开始前 30 分钟提醒
839
+ * 5开始前 60 分钟提醒
869
840
  * @returns 返回 Schedule 对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/schedule/model.html#schedule)
870
841
  */
871
- async channelsSchedulesSchedulePatch(channel_id, schedule_id, data) {
842
+ channelsSchedulesSchedulePatch(channel_id, schedule_id, data) {
872
843
  return this.guildServer({
873
844
  method: 'PATCH',
874
845
  url: `/channels/${channel_id}/schedules/${schedule_id}`,
875
846
  data
876
- }).then(res => res?.data);
847
+ });
877
848
  }
878
849
  /**
879
850
  * 删除频道日程
@@ -881,11 +852,11 @@ class QQBotAPI {
881
852
  * @param schedule_id 日程id
882
853
  * @returns
883
854
  */
884
- async channelsSchedulesScheduleDelete(channel_id, schedule_id) {
855
+ channelsSchedulesScheduleDelete(channel_id, schedule_id) {
885
856
  return this.guildServer({
886
857
  method: 'DELETE',
887
858
  url: `/channels/${channel_id}/schedules/${schedule_id}`
888
- }).then(res => res?.data);
859
+ });
889
860
  }
890
861
  /**
891
862
  * ***********
@@ -900,11 +871,11 @@ class QQBotAPI {
900
871
  * @param id 表情id 参考https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#Emoji%20%E5%88%97%E8%A1%A8
901
872
  * @returns
902
873
  */
903
- async channelsMessagesReactionsPut(channel_id, message_id, type, id) {
874
+ channelsMessagesReactionsPut(channel_id, message_id, type, id) {
904
875
  return this.guildServer({
905
876
  method: 'PUT',
906
877
  url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`
907
- }).then(res => res?.data);
878
+ });
908
879
  }
909
880
  /**
910
881
  * 删除机器人发表的表情表态
@@ -914,11 +885,11 @@ class QQBotAPI {
914
885
  * @param id 表情id 参考https://bot.q.qq.com/wiki/develop/api-v2/openapi/emoji/model.html#Emoji%20%E5%88%97%E8%A1%A8
915
886
  * @returns
916
887
  */
917
- async channelsMessagesReactionsDelete(channel_id, message_id, type, id) {
888
+ channelsMessagesReactionsDelete(channel_id, message_id, type, id) {
918
889
  return this.guildServer({
919
890
  method: 'DELETE',
920
891
  url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`
921
- }).then(res => res?.data);
892
+ });
922
893
  }
923
894
  /**
924
895
  * 获取消息表情表态的用户列表
@@ -931,12 +902,12 @@ class QQBotAPI {
931
902
  * @param {object} data.limit 返回的用户数量 默认20 最大50
932
903
  * @returns data:{ users:User[], cookie:string,is_end:true|false }
933
904
  */
934
- async channelsMessagesReactionsUsers(channel_id, message_id, type, id, data) {
905
+ channelsMessagesReactionsUsers(channel_id, message_id, type, id, data) {
935
906
  return this.guildServer({
936
907
  method: 'GET',
937
908
  url: `/channels/${channel_id}/messages/${message_id}/reactions/${type}/${id}`,
938
909
  data
939
- }).then(res => res?.data);
910
+ });
940
911
  }
941
912
  /**
942
913
  * ***********
@@ -952,34 +923,34 @@ class QQBotAPI {
952
923
  * @param text 状态文本(比如:简单爱-周杰伦),可选,status为0时传,其他操作不传
953
924
  * @returns
954
925
  */
955
- async channelsAudioPost(channel_id, data) {
926
+ channelsAudioPost(channel_id, data) {
956
927
  return this.guildServer({
957
928
  method: 'POST',
958
929
  url: `/channels/${channel_id}/audio`,
959
930
  data
960
- }).then(res => res?.data);
931
+ });
961
932
  }
962
933
  /**
963
934
  * 机器人上麦
964
935
  * @param channel_id 语音子频道id
965
936
  * @returns {}
966
937
  */
967
- async channelsMicPut(channel_id) {
938
+ channelsMicPut(channel_id) {
968
939
  return this.guildServer({
969
940
  method: 'PUT',
970
941
  url: `/channels/${channel_id}/mic`
971
- }).then(res => res?.data);
942
+ });
972
943
  }
973
944
  /**
974
945
  * 机器人下麦
975
946
  * @param channel_id 语音子频道id
976
947
  * @returns {}
977
948
  */
978
- async channelsMicDelete(channel_id) {
949
+ channelsMicDelete(channel_id) {
979
950
  return this.guildServer({
980
951
  method: 'DELETE',
981
952
  url: `/channels/${channel_id}/mic`
982
- }).then(res => res?.data);
953
+ });
983
954
  }
984
955
  /**
985
956
  * **********
@@ -996,11 +967,11 @@ class QQBotAPI {
996
967
  * @returns 返回 Thread 对象数组(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#Thread)
997
968
  * @returns is_finish 为 1 时,表示已拉取完 为 0 时,表示未拉取完
998
969
  */
999
- async channelsThreads(channel_id) {
970
+ channelsThreads(channel_id) {
1000
971
  return this.guildServer({
1001
972
  method: 'GET',
1002
973
  url: `/channels/${channel_id}/threads`
1003
- }).then(res => res?.data);
974
+ });
1004
975
  }
1005
976
  /**
1006
977
  * 获取帖子详情
@@ -1009,11 +980,11 @@ class QQBotAPI {
1009
980
  * @returns 返回 帖子详情对象(详见https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#ThreadInfo)
1010
981
  * 其中content字段可参考 https://bot.q.qq.com/wiki/develop/api-v2/server-inter/channel/content/forum/model.html#RichText
1011
982
  */
1012
- async channelsThreadsThread(channel_id, thread_id) {
983
+ channelsThreadsThread(channel_id, thread_id) {
1013
984
  return this.guildServer({
1014
985
  method: 'GET',
1015
986
  url: `/channels/${channel_id}/threads/${thread_id}`
1016
- }).then(res => res?.data);
987
+ });
1017
988
  }
1018
989
  /**
1019
990
  * 发表帖子
@@ -1023,12 +994,12 @@ class QQBotAPI {
1023
994
  * @param format 帖子内容格式 1:纯文本 2:HTML 3:Markdown 4:JSON
1024
995
  * @returns 返回 {task_id:string,create_time:string} 其中 task_id 为帖子id,create_time 发帖时间戳
1025
996
  */
1026
- async channelsThreadsPut(channel_id, data) {
997
+ channelsThreadsPut(channel_id, data) {
1027
998
  return this.guildServer({
1028
999
  method: 'PUT',
1029
1000
  url: `/channels/${channel_id}/threads`,
1030
1001
  data
1031
- }).then(res => res?.data);
1002
+ });
1032
1003
  }
1033
1004
  /**
1034
1005
  * 删除帖子
@@ -1036,11 +1007,11 @@ class QQBotAPI {
1036
1007
  * @param thread_id 帖子id
1037
1008
  * @returns
1038
1009
  */
1039
- async channelsThreadsDelete(channel_id, thread_id) {
1010
+ channelsThreadsDelete(channel_id, thread_id) {
1040
1011
  return this.guildServer({
1041
1012
  method: 'DELETE',
1042
1013
  url: `/channels/${channel_id}/threads/${thread_id}`
1043
- }).then(res => res?.data);
1014
+ });
1044
1015
  }
1045
1016
  /**
1046
1017
  * ********
@@ -1052,10 +1023,10 @@ class QQBotAPI {
1052
1023
  * @param guild_id
1053
1024
  * @returns
1054
1025
  */
1055
- async guildApiPermission(guild_id) {
1026
+ guildApiPermission(guild_id) {
1056
1027
  return this.guildServer({
1057
1028
  url: `/guilds/${guild_id}/api_permission`
1058
- }).then(res => res?.data);
1029
+ });
1059
1030
  }
1060
1031
  /**
1061
1032
  * 交互事件回应
@@ -1063,7 +1034,7 @@ class QQBotAPI {
1063
1034
  * @param code
1064
1035
  * @returns
1065
1036
  */
1066
- async interactionResponse(mode, interaction_id, code) {
1037
+ interactionResponse(mode, interaction_id, code) {
1067
1038
  if (mode === 'group') {
1068
1039
  return this.groupService({
1069
1040
  method: 'PUT',
@@ -1071,7 +1042,7 @@ class QQBotAPI {
1071
1042
  data: {
1072
1043
  code: code || 0
1073
1044
  }
1074
- }).then(res => res?.data);
1045
+ });
1075
1046
  }
1076
1047
  else {
1077
1048
  return this.guildServer({
@@ -1080,7 +1051,7 @@ class QQBotAPI {
1080
1051
  data: {
1081
1052
  code: code || 0
1082
1053
  }
1083
- }).then(res => res?.data);
1054
+ });
1084
1055
  }
1085
1056
  }
1086
1057
  }