kook-sdk 1.0.0
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/LICENSE +21 -0
- package/README.md +197 -0
- package/dist/client/http-client.d.ts +341 -0
- package/dist/client/http-client.d.ts.map +1 -0
- package/dist/client/http-client.js +919 -0
- package/dist/client/http-client.js.map +1 -0
- package/dist/client/websocket-client.d.ts +39 -0
- package/dist/client/websocket-client.d.ts.map +1 -0
- package/dist/client/websocket-client.js +321 -0
- package/dist/client/websocket-client.js.map +1 -0
- package/dist/core/bot.d.ts +362 -0
- package/dist/core/bot.d.ts.map +1 -0
- package/dist/core/bot.js +739 -0
- package/dist/core/bot.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +915 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +79 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/card-builder.d.ts +65 -0
- package/dist/utils/card-builder.d.ts.map +1 -0
- package/dist/utils/card-builder.js +192 -0
- package/dist/utils/card-builder.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +15 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/kmarkdown-builder.d.ts +193 -0
- package/dist/utils/kmarkdown-builder.d.ts.map +1 -0
- package/dist/utils/kmarkdown-builder.js +291 -0
- package/dist/utils/kmarkdown-builder.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,919 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.HttpClient = void 0;
|
|
40
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
42
|
+
const types_1 = require("../types");
|
|
43
|
+
// KOOK API 基础 URL
|
|
44
|
+
const API_BASE_URL = 'https://www.kookapp.cn/api/v3';
|
|
45
|
+
class HttpClient {
|
|
46
|
+
constructor(token) {
|
|
47
|
+
this.axios = axios_1.default.create({
|
|
48
|
+
baseURL: API_BASE_URL,
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: `Bot ${token}`,
|
|
51
|
+
'Content-Type': 'application/json',
|
|
52
|
+
},
|
|
53
|
+
timeout: 30000,
|
|
54
|
+
});
|
|
55
|
+
// 响应拦截器
|
|
56
|
+
this.axios.interceptors.response.use((response) => response, (error) => {
|
|
57
|
+
if (error.response?.data) {
|
|
58
|
+
const { code, message } = error.response.data;
|
|
59
|
+
throw new types_1.KookAPIError(code, message, error.response.data);
|
|
60
|
+
}
|
|
61
|
+
throw error;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// 通用请求方法
|
|
65
|
+
async request(config) {
|
|
66
|
+
const response = await this.axios.request(config);
|
|
67
|
+
if (response.data.code !== 0) {
|
|
68
|
+
throw new types_1.KookAPIError(response.data.code, response.data.message, response.data);
|
|
69
|
+
}
|
|
70
|
+
return response.data.data;
|
|
71
|
+
}
|
|
72
|
+
// GET 请求
|
|
73
|
+
async get(url, params) {
|
|
74
|
+
return this.request({ method: 'GET', url, params });
|
|
75
|
+
}
|
|
76
|
+
// POST 请求
|
|
77
|
+
async post(url, data) {
|
|
78
|
+
return this.request({ method: 'POST', url, data });
|
|
79
|
+
}
|
|
80
|
+
// ========== 用户相关接口 ==========
|
|
81
|
+
// 获取当前用户信息
|
|
82
|
+
async getCurrentUser() {
|
|
83
|
+
return this.get('/user/me');
|
|
84
|
+
}
|
|
85
|
+
// 获取用户详情
|
|
86
|
+
async getUser(userId) {
|
|
87
|
+
return this.get('/user/view', { user_id: userId });
|
|
88
|
+
}
|
|
89
|
+
// 下线当前用户
|
|
90
|
+
async offline() {
|
|
91
|
+
await this.post('/user/offline');
|
|
92
|
+
}
|
|
93
|
+
// ========== 服务器相关接口 ==========
|
|
94
|
+
// 获取服务器列表
|
|
95
|
+
async getGuilds() {
|
|
96
|
+
const result = await this.get('/guild/list');
|
|
97
|
+
return result.items;
|
|
98
|
+
}
|
|
99
|
+
// 获取服务器详情
|
|
100
|
+
async getGuild(guildId) {
|
|
101
|
+
return this.get('/guild/view', { guild_id: guildId });
|
|
102
|
+
}
|
|
103
|
+
// 获取服务器中的用户列表
|
|
104
|
+
async getGuildUsers(guildId, options) {
|
|
105
|
+
return this.get('/guild/user-list', {
|
|
106
|
+
guild_id: guildId,
|
|
107
|
+
...options,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// 修改服务器中用户的昵称
|
|
111
|
+
async setGuildUserNickname(guildId, userId, nickname) {
|
|
112
|
+
await this.post('/guild/nickname', {
|
|
113
|
+
guild_id: guildId,
|
|
114
|
+
user_id: userId,
|
|
115
|
+
nickname,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
// 离开服务器
|
|
119
|
+
async leaveGuild(guildId) {
|
|
120
|
+
await this.post('/guild/leave', { guild_id: guildId });
|
|
121
|
+
}
|
|
122
|
+
// 踢出服务器用户
|
|
123
|
+
async kickGuildUser(guildId, targetId) {
|
|
124
|
+
await this.post('/guild/kickout', {
|
|
125
|
+
guild_id: guildId,
|
|
126
|
+
target_id: targetId,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
// ========== 频道相关接口 ==========
|
|
130
|
+
// 获取频道列表
|
|
131
|
+
async getChannels(guildId) {
|
|
132
|
+
const result = await this.get('/channel/list', {
|
|
133
|
+
guild_id: guildId,
|
|
134
|
+
});
|
|
135
|
+
return result.items;
|
|
136
|
+
}
|
|
137
|
+
// 获取频道详情
|
|
138
|
+
async getChannel(channelId) {
|
|
139
|
+
return this.get('/channel/view', { target_id: channelId });
|
|
140
|
+
}
|
|
141
|
+
// 创建频道
|
|
142
|
+
async createChannel(guildId, name, options) {
|
|
143
|
+
return this.post('/channel/create', {
|
|
144
|
+
guild_id: guildId,
|
|
145
|
+
name,
|
|
146
|
+
...options,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
// 修改频道
|
|
150
|
+
async updateChannel(channelId, options) {
|
|
151
|
+
return this.post('/channel/update', {
|
|
152
|
+
channel_id: channelId,
|
|
153
|
+
...options,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
// 删除频道
|
|
157
|
+
async deleteChannel(channelId) {
|
|
158
|
+
await this.post('/channel/delete', { channel_id: channelId });
|
|
159
|
+
}
|
|
160
|
+
// 获取频道用户列表
|
|
161
|
+
async getChannelUsers(channelId) {
|
|
162
|
+
const result = await this.get('/channel/user-list', {
|
|
163
|
+
target_id: channelId,
|
|
164
|
+
});
|
|
165
|
+
return result.items;
|
|
166
|
+
}
|
|
167
|
+
// 移动频道
|
|
168
|
+
async moveChannel(channelId, parentId, after) {
|
|
169
|
+
await this.post('/channel/move-user', {
|
|
170
|
+
channel_id: channelId,
|
|
171
|
+
parent_id: parentId,
|
|
172
|
+
after,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
// ========== 消息相关接口 ==========
|
|
176
|
+
// 获取频道消息列表
|
|
177
|
+
async getMessages(channelId, options) {
|
|
178
|
+
return this.get('/message/list', {
|
|
179
|
+
target_id: channelId,
|
|
180
|
+
...options,
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// 获取消息详情
|
|
184
|
+
async getMessage(msgId) {
|
|
185
|
+
return this.get('/message/view', { msg_id: msgId });
|
|
186
|
+
}
|
|
187
|
+
// 发送频道消息
|
|
188
|
+
async sendChannelMessage(channelId, content, options) {
|
|
189
|
+
return this.post('/message/create', {
|
|
190
|
+
target_id: channelId,
|
|
191
|
+
content,
|
|
192
|
+
...options,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// 更新频道消息
|
|
196
|
+
async updateMessage(msgId, content, options) {
|
|
197
|
+
return this.post('/message/update', {
|
|
198
|
+
msg_id: msgId,
|
|
199
|
+
content,
|
|
200
|
+
...options,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
// 删除频道消息
|
|
204
|
+
async deleteMessage(msgId) {
|
|
205
|
+
await this.post('/message/delete', { msg_id: msgId });
|
|
206
|
+
}
|
|
207
|
+
// 获取频道消息反应列表
|
|
208
|
+
async getMessageReactions(msgId, emoji) {
|
|
209
|
+
return this.get('/message/reaction-list', {
|
|
210
|
+
msg_id: msgId,
|
|
211
|
+
emoji,
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
// 添加消息反应
|
|
215
|
+
async addMessageReaction(msgId, emoji) {
|
|
216
|
+
await this.post('/message/add-reaction', {
|
|
217
|
+
msg_id: msgId,
|
|
218
|
+
emoji,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
// 删除消息反应
|
|
222
|
+
async removeMessageReaction(msgId, emoji, userId) {
|
|
223
|
+
await this.post('/message/delete-reaction', {
|
|
224
|
+
msg_id: msgId,
|
|
225
|
+
emoji,
|
|
226
|
+
user_id: userId,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// ========== 私聊相关接口 ==========
|
|
230
|
+
// 获取私信会话列表
|
|
231
|
+
async getDirectMessageSessions() {
|
|
232
|
+
const result = await this.get('/direct-message/list');
|
|
233
|
+
return result.items;
|
|
234
|
+
}
|
|
235
|
+
// 创建私信会话
|
|
236
|
+
async createDirectMessageSession(targetId) {
|
|
237
|
+
return this.post('/direct-message/create', { target_id: targetId });
|
|
238
|
+
}
|
|
239
|
+
// 发送私信消息
|
|
240
|
+
async sendDirectMessage(targetId, content, options) {
|
|
241
|
+
return this.post('/direct-message/create', {
|
|
242
|
+
target_id: targetId,
|
|
243
|
+
content,
|
|
244
|
+
...options,
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
// ========== 角色相关接口 ==========
|
|
248
|
+
// 获取服务器角色列表
|
|
249
|
+
async getGuildRoles(guildId) {
|
|
250
|
+
const result = await this.get('/guild-role/list', { guild_id: guildId });
|
|
251
|
+
return result.items;
|
|
252
|
+
}
|
|
253
|
+
// 创建角色
|
|
254
|
+
async createRole(guildId, name, options) {
|
|
255
|
+
return this.post('/guild-role/create', {
|
|
256
|
+
guild_id: guildId,
|
|
257
|
+
name,
|
|
258
|
+
...options,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
// 更新角色
|
|
262
|
+
async updateRole(guildId, roleId, options) {
|
|
263
|
+
return this.post('/guild-role/update', {
|
|
264
|
+
guild_id: guildId,
|
|
265
|
+
role_id: roleId,
|
|
266
|
+
...options,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
// 删除角色
|
|
270
|
+
async deleteRole(guildId, roleId) {
|
|
271
|
+
await this.post('/guild-role/delete', {
|
|
272
|
+
guild_id: guildId,
|
|
273
|
+
role_id: roleId,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
// 赋予用户角色
|
|
277
|
+
async grantRole(guildId, userId, roleId) {
|
|
278
|
+
await this.post('/guild-role/grant', {
|
|
279
|
+
guild_id: guildId,
|
|
280
|
+
user_id: userId,
|
|
281
|
+
role_id: roleId,
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
// 撤销用户角色
|
|
285
|
+
async revokeRole(guildId, userId, roleId) {
|
|
286
|
+
await this.post('/guild-role/revoke', {
|
|
287
|
+
guild_id: guildId,
|
|
288
|
+
user_id: userId,
|
|
289
|
+
role_id: roleId,
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
// ========== 资源上传接口 ==========
|
|
293
|
+
// 上传文件/图片/视频
|
|
294
|
+
// 支持 Buffer、Stream 或文件路径
|
|
295
|
+
async uploadAsset(file, options) {
|
|
296
|
+
const formData = new form_data_1.default();
|
|
297
|
+
if (typeof file === 'string') {
|
|
298
|
+
// 文件路径
|
|
299
|
+
const fs = await Promise.resolve().then(() => __importStar(require('fs')));
|
|
300
|
+
const path = await Promise.resolve().then(() => __importStar(require('path')));
|
|
301
|
+
const fileStream = fs.createReadStream(file);
|
|
302
|
+
const filename = options?.filename || path.basename(file);
|
|
303
|
+
formData.append('file', fileStream, {
|
|
304
|
+
filename,
|
|
305
|
+
contentType: options?.contentType,
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
// Buffer 或 Stream
|
|
310
|
+
formData.append('file', file, {
|
|
311
|
+
filename: options?.filename || 'file',
|
|
312
|
+
contentType: options?.contentType,
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
const response = await this.axios.post('/asset/create', formData, {
|
|
316
|
+
headers: {
|
|
317
|
+
...formData.getHeaders(),
|
|
318
|
+
},
|
|
319
|
+
});
|
|
320
|
+
if (response.data.code !== 0) {
|
|
321
|
+
throw new types_1.KookAPIError(response.data.code, response.data.message, response.data);
|
|
322
|
+
}
|
|
323
|
+
return response.data.data;
|
|
324
|
+
}
|
|
325
|
+
// ========== 消息置顶接口 ==========
|
|
326
|
+
// 置顶频道消息
|
|
327
|
+
async pinMessage(msgId) {
|
|
328
|
+
await this.post('/message/pin', { msg_id: msgId });
|
|
329
|
+
}
|
|
330
|
+
// 取消置顶频道消息
|
|
331
|
+
async unpinMessage(msgId) {
|
|
332
|
+
await this.post('/message/unpin', { msg_id: msgId });
|
|
333
|
+
}
|
|
334
|
+
// ========== 语音接口 ==========
|
|
335
|
+
// 加入语音频道
|
|
336
|
+
async joinVoiceChannel(channelId, options) {
|
|
337
|
+
return this.post('/voice/join', {
|
|
338
|
+
channel_id: channelId,
|
|
339
|
+
...options,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
// 离开语音频道
|
|
343
|
+
async leaveVoiceChannel(channelId) {
|
|
344
|
+
await this.post('/voice/leave', { channel_id: channelId });
|
|
345
|
+
}
|
|
346
|
+
// 获取机器人加入的语音频道列表
|
|
347
|
+
async getVoiceChannels() {
|
|
348
|
+
return this.get('/voice/list');
|
|
349
|
+
}
|
|
350
|
+
// 保持语音连接活跃
|
|
351
|
+
async keepVoiceAlive(channelId) {
|
|
352
|
+
await this.post('/voice/keep-alive', { channel_id: channelId });
|
|
353
|
+
}
|
|
354
|
+
// ========== 邀请相关接口 ==========
|
|
355
|
+
// 获取邀请列表
|
|
356
|
+
async getInvites(guildId) {
|
|
357
|
+
const result = await this.get('/invite/list', {
|
|
358
|
+
guild_id: guildId,
|
|
359
|
+
});
|
|
360
|
+
return result.items;
|
|
361
|
+
}
|
|
362
|
+
// 创建邀请链接
|
|
363
|
+
async createInvite(channelId, options) {
|
|
364
|
+
return this.post('/invite/create', {
|
|
365
|
+
channel_id: channelId,
|
|
366
|
+
...options,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
// 删除邀请链接
|
|
370
|
+
async deleteInvite(urlCode, guildId) {
|
|
371
|
+
await this.post('/invite/delete', {
|
|
372
|
+
url_code: urlCode,
|
|
373
|
+
guild_id: guildId,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
// ========== 服务器黑名单相关接口 ==========
|
|
377
|
+
// 获取黑名单列表
|
|
378
|
+
async getBlacklist(guildId, options) {
|
|
379
|
+
return this.get('/blacklist/list', {
|
|
380
|
+
guild_id: guildId,
|
|
381
|
+
...options,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
// 添加黑名单
|
|
385
|
+
async addBlacklist(guildId, targetId, options) {
|
|
386
|
+
await this.post('/blacklist/create', {
|
|
387
|
+
guild_id: guildId,
|
|
388
|
+
target_id: targetId,
|
|
389
|
+
...options,
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
// 移除黑名单
|
|
393
|
+
async removeBlacklist(guildId, targetId) {
|
|
394
|
+
await this.post('/blacklist/delete', {
|
|
395
|
+
guild_id: guildId,
|
|
396
|
+
target_id: targetId,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
// ========== 服务器静音/闭麦相关接口 ==========
|
|
400
|
+
// 获取静音/闭麦列表
|
|
401
|
+
async getMuteList(guildId) {
|
|
402
|
+
const result = await this.get('/guild-mute/list', {
|
|
403
|
+
guild_id: guildId,
|
|
404
|
+
});
|
|
405
|
+
return result.items;
|
|
406
|
+
}
|
|
407
|
+
// 添加静音/闭麦
|
|
408
|
+
async addMute(guildId, targetId, type // 1: 麦克风静音, 2: 耳机静音
|
|
409
|
+
) {
|
|
410
|
+
await this.post('/guild-mute/create', {
|
|
411
|
+
guild_id: guildId,
|
|
412
|
+
target_id: targetId,
|
|
413
|
+
type,
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
// 移除静音/闭麦
|
|
417
|
+
async removeMute(guildId, targetId, type) {
|
|
418
|
+
await this.post('/guild-mute/delete', {
|
|
419
|
+
guild_id: guildId,
|
|
420
|
+
target_id: targetId,
|
|
421
|
+
type,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
// ========== 服务器助力相关接口 ==========
|
|
425
|
+
// 获取助力列表
|
|
426
|
+
async getBoosts(guildId) {
|
|
427
|
+
const result = await this.get('/guild-boost/list', {
|
|
428
|
+
guild_id: guildId,
|
|
429
|
+
});
|
|
430
|
+
return result.items;
|
|
431
|
+
}
|
|
432
|
+
// 获取助力历史
|
|
433
|
+
async getBoostHistory(guildId, options) {
|
|
434
|
+
return this.get('/guild-boost/history', {
|
|
435
|
+
guild_id: guildId,
|
|
436
|
+
...options,
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
// ========== 服务器表情相关接口 ==========
|
|
440
|
+
// 获取服务器表情列表
|
|
441
|
+
async getGuildEmojis(guildId) {
|
|
442
|
+
const result = await this.get('/guild-emoji/list', {
|
|
443
|
+
guild_id: guildId,
|
|
444
|
+
});
|
|
445
|
+
return result.items;
|
|
446
|
+
}
|
|
447
|
+
// 创建服务器表情
|
|
448
|
+
async createGuildEmoji(guildId, name, emoji) {
|
|
449
|
+
return this.post('/guild-emoji/create', {
|
|
450
|
+
guild_id: guildId,
|
|
451
|
+
name,
|
|
452
|
+
emoji,
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
// 更新服务器表情
|
|
456
|
+
async updateGuildEmoji(guildId, emojiId, name) {
|
|
457
|
+
return this.post('/guild-emoji/update', {
|
|
458
|
+
guild_id: guildId,
|
|
459
|
+
id: emojiId,
|
|
460
|
+
name,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
// 删除服务器表情
|
|
464
|
+
async deleteGuildEmoji(guildId, emojiId) {
|
|
465
|
+
await this.post('/guild-emoji/delete', {
|
|
466
|
+
guild_id: guildId,
|
|
467
|
+
emoji_id: emojiId,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
// ========== 服务器公告相关接口 ==========
|
|
471
|
+
// 获取公告列表
|
|
472
|
+
async getAnnouncements(guildId, options) {
|
|
473
|
+
return this.get('/announcement/list', {
|
|
474
|
+
guild_id: guildId,
|
|
475
|
+
...options,
|
|
476
|
+
});
|
|
477
|
+
}
|
|
478
|
+
// 创建公告
|
|
479
|
+
async createAnnouncement(guildId, channelId, content) {
|
|
480
|
+
return this.post('/announcement/create', {
|
|
481
|
+
guild_id: guildId,
|
|
482
|
+
channel_id: channelId,
|
|
483
|
+
content,
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
// 更新公告
|
|
487
|
+
async updateAnnouncement(announcementId, content) {
|
|
488
|
+
return this.post('/announcement/update', {
|
|
489
|
+
id: announcementId,
|
|
490
|
+
content,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
// 删除公告
|
|
494
|
+
async deleteAnnouncement(announcementId) {
|
|
495
|
+
await this.post('/announcement/delete', { id: announcementId });
|
|
496
|
+
}
|
|
497
|
+
// ========== 服务器积分相关接口 ==========
|
|
498
|
+
// 获取积分排行
|
|
499
|
+
async getIntimacyRank(guildId, options) {
|
|
500
|
+
return this.get('/intimacy/rank', {
|
|
501
|
+
guild_id: guildId,
|
|
502
|
+
...options,
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
// 获取用户积分信息
|
|
506
|
+
async getIntimacyInfo(userId, guildId) {
|
|
507
|
+
return this.get('/intimacy/index', {
|
|
508
|
+
user_id: userId,
|
|
509
|
+
guild_id: guildId,
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
// 更新用户积分
|
|
513
|
+
async updateIntimacy(userId, guildId, score) {
|
|
514
|
+
await this.post('/intimacy/update', {
|
|
515
|
+
user_id: userId,
|
|
516
|
+
guild_id: guildId,
|
|
517
|
+
score,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
// ========== 游戏相关接口 ==========
|
|
521
|
+
// 获取游戏列表
|
|
522
|
+
async getGames() {
|
|
523
|
+
const result = await this.get('/game');
|
|
524
|
+
return result.items;
|
|
525
|
+
}
|
|
526
|
+
// 创建游戏
|
|
527
|
+
async createGame(name, icon, options) {
|
|
528
|
+
return this.post('/game/create', {
|
|
529
|
+
name,
|
|
530
|
+
icon,
|
|
531
|
+
...options,
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
// 更新游戏
|
|
535
|
+
async updateGame(gameId, options) {
|
|
536
|
+
return this.post('/game/update', {
|
|
537
|
+
id: gameId,
|
|
538
|
+
...options,
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
// 删除游戏
|
|
542
|
+
async deleteGame(gameId) {
|
|
543
|
+
await this.post('/game/delete', { id: gameId });
|
|
544
|
+
}
|
|
545
|
+
// 开始玩游戏
|
|
546
|
+
async startPlaying(gameId) {
|
|
547
|
+
await this.post('/game/activity', {
|
|
548
|
+
id: gameId,
|
|
549
|
+
data_type: 1,
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
// 结束玩游戏
|
|
553
|
+
async stopPlaying(gameId) {
|
|
554
|
+
await this.post('/game/delete-activity', { id: gameId });
|
|
555
|
+
}
|
|
556
|
+
// ========== 徽章相关接口 ==========
|
|
557
|
+
// 获取徽章列表
|
|
558
|
+
async getBadges(guildId) {
|
|
559
|
+
const result = await this.get('/badge/list', {
|
|
560
|
+
guild_id: guildId,
|
|
561
|
+
});
|
|
562
|
+
return result.items;
|
|
563
|
+
}
|
|
564
|
+
// 创建徽章
|
|
565
|
+
async createBadge(guildId, name, icon, options) {
|
|
566
|
+
return this.post('/badge/create', {
|
|
567
|
+
guild_id: guildId,
|
|
568
|
+
name,
|
|
569
|
+
icon,
|
|
570
|
+
...options,
|
|
571
|
+
});
|
|
572
|
+
}
|
|
573
|
+
// 更新徽章
|
|
574
|
+
async updateBadge(badgeId, options) {
|
|
575
|
+
return this.post('/badge/update', {
|
|
576
|
+
id: badgeId,
|
|
577
|
+
...options,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
// 删除徽章
|
|
581
|
+
async deleteBadge(badgeId) {
|
|
582
|
+
await this.post('/badge/delete', { id: badgeId });
|
|
583
|
+
}
|
|
584
|
+
// 授予用户徽章
|
|
585
|
+
async grantBadge(guildId, userId, badgeId) {
|
|
586
|
+
await this.post('/badge/grant', {
|
|
587
|
+
guild_id: guildId,
|
|
588
|
+
user_id: userId,
|
|
589
|
+
badge_id: badgeId,
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
// 撤销用户徽章
|
|
593
|
+
async revokeBadge(guildId, userId, badgeId) {
|
|
594
|
+
await this.post('/badge/revoke', {
|
|
595
|
+
guild_id: guildId,
|
|
596
|
+
user_id: userId,
|
|
597
|
+
badge_id: badgeId,
|
|
598
|
+
});
|
|
599
|
+
}
|
|
600
|
+
// ========== 服务器日程相关接口 ==========
|
|
601
|
+
// 获取日程列表
|
|
602
|
+
async getSchedules(channelId, options) {
|
|
603
|
+
return this.get('/schedule/list', {
|
|
604
|
+
channel_id: channelId,
|
|
605
|
+
...options,
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
// 获取日程详情
|
|
609
|
+
async getSchedule(scheduleId) {
|
|
610
|
+
return this.get('/schedule/view', { id: scheduleId });
|
|
611
|
+
}
|
|
612
|
+
// 创建日程
|
|
613
|
+
async createSchedule(channelId, title, startTime, endTime, options) {
|
|
614
|
+
return this.post('/schedule/create', {
|
|
615
|
+
channel_id: channelId,
|
|
616
|
+
title,
|
|
617
|
+
start_time: startTime,
|
|
618
|
+
end_time: endTime,
|
|
619
|
+
...options,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
// 更新日程
|
|
623
|
+
async updateSchedule(scheduleId, options) {
|
|
624
|
+
return this.post('/schedule/update', {
|
|
625
|
+
id: scheduleId,
|
|
626
|
+
...options,
|
|
627
|
+
});
|
|
628
|
+
}
|
|
629
|
+
// 删除日程
|
|
630
|
+
async deleteSchedule(scheduleId) {
|
|
631
|
+
await this.post('/schedule/delete', { id: scheduleId });
|
|
632
|
+
}
|
|
633
|
+
// ========== 频道分组相关接口 ==========
|
|
634
|
+
// 获取频道分组列表
|
|
635
|
+
async getChannelCategories(guildId) {
|
|
636
|
+
const result = await this.get('/channel/list', {
|
|
637
|
+
guild_id: guildId,
|
|
638
|
+
});
|
|
639
|
+
return result.items.filter((item) => item.is_category);
|
|
640
|
+
}
|
|
641
|
+
// 创建频道分组
|
|
642
|
+
async createChannelCategory(guildId, name) {
|
|
643
|
+
return this.post('/channel/create', {
|
|
644
|
+
guild_id: guildId,
|
|
645
|
+
name,
|
|
646
|
+
is_category: true,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
// 更新频道分组
|
|
650
|
+
async updateChannelCategory(categoryId, name) {
|
|
651
|
+
return this.post('/channel/update', {
|
|
652
|
+
channel_id: categoryId,
|
|
653
|
+
name,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
// 删除频道分组
|
|
657
|
+
async deleteChannelCategory(categoryId) {
|
|
658
|
+
await this.post('/channel/delete', { channel_id: categoryId });
|
|
659
|
+
}
|
|
660
|
+
// 移动频道到分组
|
|
661
|
+
async moveChannelToCategory(channelId, parentId) {
|
|
662
|
+
await this.post('/channel/move-user', {
|
|
663
|
+
channel_id: channelId,
|
|
664
|
+
parent_id: parentId,
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
// ========== 用户聊天相关接口 ==========
|
|
668
|
+
// 获取用户聊天会话列表
|
|
669
|
+
async getUserChats() {
|
|
670
|
+
const result = await this.get('/user-chat/list');
|
|
671
|
+
return result.items;
|
|
672
|
+
}
|
|
673
|
+
// 获取用户聊天会话详情
|
|
674
|
+
async getUserChat(chatId) {
|
|
675
|
+
return this.get('/user-chat/view', { chat_id: chatId });
|
|
676
|
+
}
|
|
677
|
+
// 创建用户聊天会话
|
|
678
|
+
async createUserChat(targetId) {
|
|
679
|
+
return this.post('/user-chat/create', { target_id: targetId });
|
|
680
|
+
}
|
|
681
|
+
// 删除用户聊天会话
|
|
682
|
+
async deleteUserChat(chatId) {
|
|
683
|
+
await this.post('/user-chat/delete', { chat_id: chatId });
|
|
684
|
+
}
|
|
685
|
+
// ========== 频道角色权限相关接口 ==========
|
|
686
|
+
// 获取频道角色权限列表
|
|
687
|
+
async getChannelRolePermissions(channelId) {
|
|
688
|
+
const result = await this.get('/channel-role/index', {
|
|
689
|
+
channel_id: channelId,
|
|
690
|
+
});
|
|
691
|
+
return result.items;
|
|
692
|
+
}
|
|
693
|
+
// 创建频道角色权限
|
|
694
|
+
async createChannelRolePermission(channelId, roleId, allow, deny) {
|
|
695
|
+
return this.post('/channel-role/create', {
|
|
696
|
+
channel_id: channelId,
|
|
697
|
+
role_id: roleId,
|
|
698
|
+
allow,
|
|
699
|
+
deny,
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
// 更新频道角色权限
|
|
703
|
+
async updateChannelRolePermission(channelId, roleId, allow, deny) {
|
|
704
|
+
return this.post('/channel-role/update', {
|
|
705
|
+
channel_id: channelId,
|
|
706
|
+
role_id: roleId,
|
|
707
|
+
allow,
|
|
708
|
+
deny,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
// 删除频道角色权限
|
|
712
|
+
async deleteChannelRolePermission(channelId, roleId) {
|
|
713
|
+
await this.post('/channel-role/delete', {
|
|
714
|
+
channel_id: channelId,
|
|
715
|
+
role_id: roleId,
|
|
716
|
+
});
|
|
717
|
+
}
|
|
718
|
+
// ========== 频道用户权限相关接口 ==========
|
|
719
|
+
// 获取频道用户权限列表
|
|
720
|
+
async getChannelUserPermissions(channelId) {
|
|
721
|
+
const result = await this.get('/channel-user/index', {
|
|
722
|
+
channel_id: channelId,
|
|
723
|
+
});
|
|
724
|
+
return result.items;
|
|
725
|
+
}
|
|
726
|
+
// 创建频道用户权限
|
|
727
|
+
async createChannelUserPermission(channelId, userId, allow, deny) {
|
|
728
|
+
return this.post('/channel-user/create', {
|
|
729
|
+
channel_id: channelId,
|
|
730
|
+
user_id: userId,
|
|
731
|
+
allow,
|
|
732
|
+
deny,
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
// 更新频道用户权限
|
|
736
|
+
async updateChannelUserPermission(channelId, userId, allow, deny) {
|
|
737
|
+
return this.post('/channel-user/update', {
|
|
738
|
+
channel_id: channelId,
|
|
739
|
+
user_id: userId,
|
|
740
|
+
allow,
|
|
741
|
+
deny,
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
// 删除频道用户权限
|
|
745
|
+
async deleteChannelUserPermission(channelId, userId) {
|
|
746
|
+
await this.post('/channel-user/delete', {
|
|
747
|
+
channel_id: channelId,
|
|
748
|
+
user_id: userId,
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
// ========== 服务器打卡相关接口 ==========
|
|
752
|
+
// 获取服务器打卡信息
|
|
753
|
+
async getPunchIn(guildId) {
|
|
754
|
+
return this.get('/punch-in/index', { guild_id: guildId });
|
|
755
|
+
}
|
|
756
|
+
// 服务器打卡
|
|
757
|
+
async punchIn(guildId) {
|
|
758
|
+
await this.post('/punch-in/punch-in', { guild_id: guildId });
|
|
759
|
+
}
|
|
760
|
+
// ========== 批量相关接口 ==========
|
|
761
|
+
// 批量获取用户信息
|
|
762
|
+
async getUsersBatch(userIds) {
|
|
763
|
+
const result = await this.post('/user/batch-get-user-info', {
|
|
764
|
+
user_ids: userIds,
|
|
765
|
+
});
|
|
766
|
+
return result.items;
|
|
767
|
+
}
|
|
768
|
+
// 批量获取服务器信息
|
|
769
|
+
async getGuildsBatch(guildIds) {
|
|
770
|
+
const result = await this.post('/guild/batch-get-guild-info', {
|
|
771
|
+
guild_ids: guildIds,
|
|
772
|
+
});
|
|
773
|
+
return result.items;
|
|
774
|
+
}
|
|
775
|
+
// ========== 服务器设置相关接口 ==========
|
|
776
|
+
// 获取服务器设置
|
|
777
|
+
async getGuildSettings(guildId) {
|
|
778
|
+
return this.get('/guild-setting/index', { guild_id: guildId });
|
|
779
|
+
}
|
|
780
|
+
// ========== 网关相关接口 ==========
|
|
781
|
+
// 获取网关连接地址
|
|
782
|
+
async getGateway(compress) {
|
|
783
|
+
return this.get('/gateway/index', { compress });
|
|
784
|
+
}
|
|
785
|
+
// ========== 服务器欢迎设置相关接口 ==========
|
|
786
|
+
// 获取服务器欢迎设置
|
|
787
|
+
async getGuildWelcome(guildId) {
|
|
788
|
+
return this.get('/guild-welcome/index', { guild_id: guildId });
|
|
789
|
+
}
|
|
790
|
+
// 更新服务器欢迎设置
|
|
791
|
+
async updateGuildWelcome(guildId, options) {
|
|
792
|
+
return this.post('/guild-welcome/update', {
|
|
793
|
+
guild_id: guildId,
|
|
794
|
+
...options,
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
// ========== 服务器通知设置相关接口 ==========
|
|
798
|
+
// 获取服务器通知设置
|
|
799
|
+
async getGuildNotify(guildId) {
|
|
800
|
+
return this.get('/guild-notify/index', { guild_id: guildId });
|
|
801
|
+
}
|
|
802
|
+
// 更新服务器通知设置
|
|
803
|
+
async updateGuildNotify(guildId, notifyType) {
|
|
804
|
+
return this.post('/guild-notify/update', {
|
|
805
|
+
guild_id: guildId,
|
|
806
|
+
notify_type: notifyType,
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
// ========== 私聊消息相关扩展接口 ==========
|
|
810
|
+
// 获取私聊消息详情
|
|
811
|
+
async getDirectMessageDetail(msgId) {
|
|
812
|
+
return this.get('/direct-message/view', { msg_id: msgId });
|
|
813
|
+
}
|
|
814
|
+
// 更新私聊消息
|
|
815
|
+
async updateDirectMessage(msgId, content, options) {
|
|
816
|
+
return this.post('/direct-message/update', {
|
|
817
|
+
msg_id: msgId,
|
|
818
|
+
content,
|
|
819
|
+
...options,
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
// 删除私聊消息
|
|
823
|
+
async deleteDirectMessage(msgId) {
|
|
824
|
+
await this.post('/direct-message/delete', { msg_id: msgId });
|
|
825
|
+
}
|
|
826
|
+
// ========== 消息相关扩展接口 ==========
|
|
827
|
+
// 添加消息阅读回执
|
|
828
|
+
async addMessageReadReceipt(msgId) {
|
|
829
|
+
await this.post('/message/add-receipt', { msg_id: msgId });
|
|
830
|
+
}
|
|
831
|
+
// 获取消息阅读回执列表
|
|
832
|
+
async getMessageReadReceipts(msgId) {
|
|
833
|
+
return this.get('/message/receipt-list', { msg_id: msgId });
|
|
834
|
+
}
|
|
835
|
+
// ========== 频道相关扩展接口 ==========
|
|
836
|
+
// 设置频道语音质量
|
|
837
|
+
async setVoiceQuality(channelId, quality) {
|
|
838
|
+
await this.post('/channel/set-voice-quality', {
|
|
839
|
+
channel_id: channelId,
|
|
840
|
+
voice_quality: quality,
|
|
841
|
+
});
|
|
842
|
+
}
|
|
843
|
+
// 设置频道慢速模式
|
|
844
|
+
async setSlowMode(channelId, slowMode) {
|
|
845
|
+
await this.post('/channel/set-slow-mode', {
|
|
846
|
+
channel_id: channelId,
|
|
847
|
+
slow_mode: slowMode,
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
// ========== 服务器角色权限相关扩展接口 ==========
|
|
851
|
+
// 批量更新服务器角色权限
|
|
852
|
+
async batchUpdateGuildRolePermissions(guildId, permissions) {
|
|
853
|
+
await this.post('/guild-role/batch-update-permissions', {
|
|
854
|
+
guild_id: guildId,
|
|
855
|
+
permissions,
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
// ========== 用户相关扩展接口 ==========
|
|
859
|
+
// 获取用户好友列表
|
|
860
|
+
async getFriends() {
|
|
861
|
+
const result = await this.get('/friend/list');
|
|
862
|
+
return result.items;
|
|
863
|
+
}
|
|
864
|
+
// 获取好友申请列表
|
|
865
|
+
async getFriendRequests() {
|
|
866
|
+
return this.get('/friend/request-list');
|
|
867
|
+
}
|
|
868
|
+
// 发送好友申请
|
|
869
|
+
async sendFriendRequest(targetId, content) {
|
|
870
|
+
await this.post('/friend/request', {
|
|
871
|
+
target_id: targetId,
|
|
872
|
+
content,
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
// 接受好友申请
|
|
876
|
+
async acceptFriendRequest(targetId) {
|
|
877
|
+
await this.post('/friend/accept', { target_id: targetId });
|
|
878
|
+
}
|
|
879
|
+
// 拒绝好友申请
|
|
880
|
+
async declineFriendRequest(targetId) {
|
|
881
|
+
await this.post('/friend/decline', { target_id: targetId });
|
|
882
|
+
}
|
|
883
|
+
// 删除好友
|
|
884
|
+
async deleteFriend(targetId) {
|
|
885
|
+
await this.post('/friend/delete', { target_id: targetId });
|
|
886
|
+
}
|
|
887
|
+
// ========== 服务器成员相关扩展接口 ==========
|
|
888
|
+
// 获取服务器成员在线状态
|
|
889
|
+
async getGuildMemberOnlineStatus(guildId, userId) {
|
|
890
|
+
return this.get('/guild/user-online-status', {
|
|
891
|
+
guild_id: guildId,
|
|
892
|
+
user_id: userId,
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
// 获取服务器成员权限
|
|
896
|
+
async getGuildMemberPermissions(guildId, userId) {
|
|
897
|
+
return this.get('/guild/user-permissions', {
|
|
898
|
+
guild_id: guildId,
|
|
899
|
+
user_id: userId,
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
// ========== 批量操作相关扩展接口 ==========
|
|
903
|
+
// 批量获取频道信息
|
|
904
|
+
async getChannelsBatch(channelIds) {
|
|
905
|
+
const result = await this.post('/channel/batch-get-channel-info', {
|
|
906
|
+
channel_ids: channelIds,
|
|
907
|
+
});
|
|
908
|
+
return result.items;
|
|
909
|
+
}
|
|
910
|
+
// 批量获取消息信息
|
|
911
|
+
async getMessagesBatch(msgIds) {
|
|
912
|
+
const result = await this.post('/message/batch-get-message-info', {
|
|
913
|
+
msg_ids: msgIds,
|
|
914
|
+
});
|
|
915
|
+
return result.items;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
exports.HttpClient = HttpClient;
|
|
919
|
+
//# sourceMappingURL=http-client.js.map
|