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
package/dist/core/bot.js
ADDED
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KookBot = void 0;
|
|
4
|
+
const events_1 = require("events");
|
|
5
|
+
const http_client_1 = require("../client/http-client");
|
|
6
|
+
const websocket_client_1 = require("../client/websocket-client");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
class KookBot extends events_1.EventEmitter {
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this.wsClient = null;
|
|
12
|
+
this.isRunning = false;
|
|
13
|
+
this.options = options;
|
|
14
|
+
this.httpClient = new http_client_1.HttpClient(options.token);
|
|
15
|
+
}
|
|
16
|
+
// 启动机器人
|
|
17
|
+
async start() {
|
|
18
|
+
if (this.isRunning) {
|
|
19
|
+
throw new Error('Bot is already running');
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
// 验证 token 并获取当前用户信息
|
|
23
|
+
const user = await this.httpClient.getCurrentUser();
|
|
24
|
+
this.emit('debug', `Bot user: ${user.username}#${user.identify_num}`);
|
|
25
|
+
// 连接到 WebSocket
|
|
26
|
+
this.wsClient = new websocket_client_1.WebSocketClient({
|
|
27
|
+
token: this.options.token,
|
|
28
|
+
compress: this.options.compress,
|
|
29
|
+
autoReconnect: this.options.autoReconnect ?? true,
|
|
30
|
+
reconnectInterval: this.options.reconnectInterval ?? 5000,
|
|
31
|
+
maxReconnectAttempts: this.options.maxReconnectAttempts ?? 10,
|
|
32
|
+
});
|
|
33
|
+
this.setupEventHandlers();
|
|
34
|
+
await this.wsClient.connect();
|
|
35
|
+
this.isRunning = true;
|
|
36
|
+
this.emit('ready', user);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
this.emit('error', error);
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// 停止机器人
|
|
44
|
+
async stop() {
|
|
45
|
+
if (!this.isRunning) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.wsClient?.disconnect();
|
|
49
|
+
this.wsClient = null;
|
|
50
|
+
this.isRunning = false;
|
|
51
|
+
this.emit('stopped');
|
|
52
|
+
}
|
|
53
|
+
// 设置事件处理器
|
|
54
|
+
setupEventHandlers() {
|
|
55
|
+
if (!this.wsClient)
|
|
56
|
+
return;
|
|
57
|
+
// WebSocket 事件
|
|
58
|
+
this.wsClient.on('ready', () => {
|
|
59
|
+
this.emit('debug', 'WebSocket ready');
|
|
60
|
+
});
|
|
61
|
+
this.wsClient.on('error', (error) => {
|
|
62
|
+
this.emit('error', error);
|
|
63
|
+
});
|
|
64
|
+
this.wsClient.on('debug', (message) => {
|
|
65
|
+
this.emit('debug', message);
|
|
66
|
+
});
|
|
67
|
+
// 消息事件
|
|
68
|
+
this.wsClient.on('message', (event) => {
|
|
69
|
+
this.emit('message', event);
|
|
70
|
+
this.emit('messageCreate', event);
|
|
71
|
+
});
|
|
72
|
+
// 系统事件
|
|
73
|
+
this.wsClient.on('joined_guild', (event) => {
|
|
74
|
+
this.emit('joinedGuild', event);
|
|
75
|
+
});
|
|
76
|
+
this.wsClient.on('exited_guild', (event) => {
|
|
77
|
+
this.emit('exitedGuild', event);
|
|
78
|
+
});
|
|
79
|
+
this.wsClient.on('guild_member_online', (event) => {
|
|
80
|
+
this.emit('guildMemberOnline', event);
|
|
81
|
+
});
|
|
82
|
+
this.wsClient.on('guild_member_offline', (event) => {
|
|
83
|
+
this.emit('guildMemberOffline', event);
|
|
84
|
+
});
|
|
85
|
+
this.wsClient.on('guild_member_update', (event) => {
|
|
86
|
+
this.emit('guildMemberUpdate', event);
|
|
87
|
+
});
|
|
88
|
+
this.wsClient.on('channel_create', (event) => {
|
|
89
|
+
this.emit('channelCreate', event);
|
|
90
|
+
});
|
|
91
|
+
this.wsClient.on('channel_delete', (event) => {
|
|
92
|
+
this.emit('channelDelete', event);
|
|
93
|
+
});
|
|
94
|
+
this.wsClient.on('channel_update', (event) => {
|
|
95
|
+
this.emit('channelUpdate', event);
|
|
96
|
+
});
|
|
97
|
+
this.wsClient.on('message_delete', (event) => {
|
|
98
|
+
this.emit('messageDelete', event);
|
|
99
|
+
});
|
|
100
|
+
this.wsClient.on('message_update', (event) => {
|
|
101
|
+
this.emit('messageUpdate', event);
|
|
102
|
+
});
|
|
103
|
+
this.wsClient.on('reaction_add', (event) => {
|
|
104
|
+
this.emit('reactionAdd', event);
|
|
105
|
+
});
|
|
106
|
+
this.wsClient.on('reaction_remove', (event) => {
|
|
107
|
+
this.emit('reactionRemove', event);
|
|
108
|
+
});
|
|
109
|
+
this.wsClient.on('guild_update', (event) => {
|
|
110
|
+
this.emit('guildUpdate', event);
|
|
111
|
+
});
|
|
112
|
+
this.wsClient.on('guild_role_create', (event) => {
|
|
113
|
+
this.emit('guildRoleCreate', event);
|
|
114
|
+
});
|
|
115
|
+
this.wsClient.on('guild_role_delete', (event) => {
|
|
116
|
+
this.emit('guildRoleDelete', event);
|
|
117
|
+
});
|
|
118
|
+
this.wsClient.on('guild_role_update', (event) => {
|
|
119
|
+
this.emit('guildRoleUpdate', event);
|
|
120
|
+
});
|
|
121
|
+
this.wsClient.on('message_btn_click', (event) => {
|
|
122
|
+
this.emit('messageBtnClick', event);
|
|
123
|
+
});
|
|
124
|
+
// 新增事件 - 服务器封禁
|
|
125
|
+
this.wsClient.on('added_block_list', (event) => {
|
|
126
|
+
this.emit('addedBlockList', event);
|
|
127
|
+
});
|
|
128
|
+
this.wsClient.on('deleted_block_list', (event) => {
|
|
129
|
+
this.emit('deletedBlockList', event);
|
|
130
|
+
});
|
|
131
|
+
// 新增事件 - 服务器表情
|
|
132
|
+
this.wsClient.on('added_emoji', (event) => {
|
|
133
|
+
this.emit('addedEmoji', event);
|
|
134
|
+
});
|
|
135
|
+
this.wsClient.on('removed_emoji', (event) => {
|
|
136
|
+
this.emit('removedEmoji', event);
|
|
137
|
+
});
|
|
138
|
+
this.wsClient.on('updated_emoji', (event) => {
|
|
139
|
+
this.emit('updatedEmoji', event);
|
|
140
|
+
});
|
|
141
|
+
// 新增事件 - 消息置顶
|
|
142
|
+
this.wsClient.on('pinned_message', (event) => {
|
|
143
|
+
this.emit('pinnedMessage', event);
|
|
144
|
+
});
|
|
145
|
+
this.wsClient.on('unpinned_message', (event) => {
|
|
146
|
+
this.emit('unpinnedMessage', event);
|
|
147
|
+
});
|
|
148
|
+
// 新增事件 - 语音频道
|
|
149
|
+
this.wsClient.on('joined_channel', (event) => {
|
|
150
|
+
this.emit('joinedChannel', event);
|
|
151
|
+
});
|
|
152
|
+
this.wsClient.on('exited_channel', (event) => {
|
|
153
|
+
this.emit('exitedChannel', event);
|
|
154
|
+
});
|
|
155
|
+
// 新增事件 - 用户更新
|
|
156
|
+
this.wsClient.on('user_update', (event) => {
|
|
157
|
+
this.emit('userUpdate', event);
|
|
158
|
+
});
|
|
159
|
+
// 新增事件 - 自己加入/退出服务器
|
|
160
|
+
this.wsClient.on('self_joined_guild', (event) => {
|
|
161
|
+
this.emit('selfJoinedGuild', event);
|
|
162
|
+
});
|
|
163
|
+
this.wsClient.on('self_exited_guild', (event) => {
|
|
164
|
+
this.emit('selfExitedGuild', event);
|
|
165
|
+
});
|
|
166
|
+
// 通用系统事件
|
|
167
|
+
this.wsClient.on('system_event', (event) => {
|
|
168
|
+
this.emit('systemEvent', event);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
// ========== HTTP API 代理方法 ==========
|
|
172
|
+
// 获取当前用户
|
|
173
|
+
async getCurrentUser() {
|
|
174
|
+
return this.httpClient.getCurrentUser();
|
|
175
|
+
}
|
|
176
|
+
// 获取用户详情
|
|
177
|
+
async getUser(userId) {
|
|
178
|
+
return this.httpClient.getUser(userId);
|
|
179
|
+
}
|
|
180
|
+
// 获取服务器列表
|
|
181
|
+
async getGuilds() {
|
|
182
|
+
return this.httpClient.getGuilds();
|
|
183
|
+
}
|
|
184
|
+
// 获取服务器详情
|
|
185
|
+
async getGuild(guildId) {
|
|
186
|
+
return this.httpClient.getGuild(guildId);
|
|
187
|
+
}
|
|
188
|
+
// 获取频道列表
|
|
189
|
+
async getChannels(guildId) {
|
|
190
|
+
return this.httpClient.getChannels(guildId);
|
|
191
|
+
}
|
|
192
|
+
// 获取频道详情
|
|
193
|
+
async getChannel(channelId) {
|
|
194
|
+
return this.httpClient.getChannel(channelId);
|
|
195
|
+
}
|
|
196
|
+
// 获取消息列表
|
|
197
|
+
async getMessages(channelId, options) {
|
|
198
|
+
return this.httpClient.getMessages(channelId, options);
|
|
199
|
+
}
|
|
200
|
+
// 获取消息详情
|
|
201
|
+
async getMessage(msgId) {
|
|
202
|
+
return this.httpClient.getMessage(msgId);
|
|
203
|
+
}
|
|
204
|
+
// ========== 消息发送方法 ==========
|
|
205
|
+
// 发送文本消息
|
|
206
|
+
async sendTextMessage(channelId, content, options) {
|
|
207
|
+
return this.httpClient.sendChannelMessage(channelId, content, {
|
|
208
|
+
type: types_1.MessageType.TEXT,
|
|
209
|
+
...options,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// 发送 KMarkdown 消息
|
|
213
|
+
async sendKMarkdownMessage(channelId, content, options) {
|
|
214
|
+
return this.httpClient.sendChannelMessage(channelId, content, {
|
|
215
|
+
type: types_1.MessageType.KMARKDOWN,
|
|
216
|
+
...options,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
// 发送卡片消息
|
|
220
|
+
async sendCardMessage(channelId, cards, options) {
|
|
221
|
+
const cardArray = Array.isArray(cards) ? cards : [cards];
|
|
222
|
+
return this.httpClient.sendChannelMessage(channelId, JSON.stringify(cardArray), {
|
|
223
|
+
type: types_1.MessageType.CARD,
|
|
224
|
+
...options,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
// 发送图片消息
|
|
228
|
+
async sendImageMessage(channelId, imageUrl, options) {
|
|
229
|
+
return this.httpClient.sendChannelMessage(channelId, imageUrl, {
|
|
230
|
+
type: types_1.MessageType.IMAGE,
|
|
231
|
+
...options,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
// 发送视频消息
|
|
235
|
+
async sendVideoMessage(channelId, videoUrl, options) {
|
|
236
|
+
return this.httpClient.sendChannelMessage(channelId, videoUrl, {
|
|
237
|
+
type: types_1.MessageType.VIDEO,
|
|
238
|
+
...options,
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
// 发送文件消息
|
|
242
|
+
async sendFileMessage(channelId, fileUrl, options) {
|
|
243
|
+
return this.httpClient.sendChannelMessage(channelId, fileUrl, {
|
|
244
|
+
type: types_1.MessageType.FILE,
|
|
245
|
+
...options,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
// 发送音频消息
|
|
249
|
+
async sendAudioMessage(channelId, audioUrl, options) {
|
|
250
|
+
return this.httpClient.sendChannelMessage(channelId, audioUrl, {
|
|
251
|
+
type: types_1.MessageType.AUDIO,
|
|
252
|
+
...options,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
// 更新消息
|
|
256
|
+
async updateMessage(msgId, content, options) {
|
|
257
|
+
return this.httpClient.updateMessage(msgId, content, options);
|
|
258
|
+
}
|
|
259
|
+
// 删除消息
|
|
260
|
+
async deleteMessage(msgId) {
|
|
261
|
+
return this.httpClient.deleteMessage(msgId);
|
|
262
|
+
}
|
|
263
|
+
// 添加消息反应
|
|
264
|
+
async addReaction(msgId, emoji) {
|
|
265
|
+
return this.httpClient.addMessageReaction(msgId, emoji);
|
|
266
|
+
}
|
|
267
|
+
// 删除消息反应
|
|
268
|
+
async removeReaction(msgId, emoji, userId) {
|
|
269
|
+
return this.httpClient.removeMessageReaction(msgId, emoji, userId);
|
|
270
|
+
}
|
|
271
|
+
// ========== 私聊相关方法 ==========
|
|
272
|
+
// 发送私信
|
|
273
|
+
async sendDirectMessage(targetId, content, options) {
|
|
274
|
+
return this.httpClient.sendDirectMessage(targetId, content, options);
|
|
275
|
+
}
|
|
276
|
+
// 发送私信文本
|
|
277
|
+
async sendDirectTextMessage(targetId, content, options) {
|
|
278
|
+
return this.httpClient.sendDirectMessage(targetId, content, {
|
|
279
|
+
type: types_1.MessageType.TEXT,
|
|
280
|
+
...options,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// 发送私信 KMarkdown
|
|
284
|
+
async sendDirectKMarkdownMessage(targetId, content, options) {
|
|
285
|
+
return this.httpClient.sendDirectMessage(targetId, content, {
|
|
286
|
+
type: types_1.MessageType.KMARKDOWN,
|
|
287
|
+
...options,
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// 发送私信卡片
|
|
291
|
+
async sendDirectCardMessage(targetId, cards, options) {
|
|
292
|
+
const cardArray = Array.isArray(cards) ? cards : [cards];
|
|
293
|
+
return this.httpClient.sendDirectMessage(targetId, JSON.stringify(cardArray), {
|
|
294
|
+
type: types_1.MessageType.CARD,
|
|
295
|
+
...options,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
// ========== 服务器管理方法 ==========
|
|
299
|
+
// 获取服务器成员列表
|
|
300
|
+
async getGuildUsers(guildId, options) {
|
|
301
|
+
return this.httpClient.getGuildUsers(guildId, options);
|
|
302
|
+
}
|
|
303
|
+
// 设置用户昵称
|
|
304
|
+
async setNickname(guildId, userId, nickname) {
|
|
305
|
+
return this.httpClient.setGuildUserNickname(guildId, userId, nickname);
|
|
306
|
+
}
|
|
307
|
+
// 踢出用户
|
|
308
|
+
async kickUser(guildId, targetId) {
|
|
309
|
+
return this.httpClient.kickGuildUser(guildId, targetId);
|
|
310
|
+
}
|
|
311
|
+
// ========== 角色管理方法 ==========
|
|
312
|
+
// 获取角色列表
|
|
313
|
+
async getRoles(guildId) {
|
|
314
|
+
return this.httpClient.getGuildRoles(guildId);
|
|
315
|
+
}
|
|
316
|
+
// 赋予角色
|
|
317
|
+
async grantRole(guildId, userId, roleId) {
|
|
318
|
+
return this.httpClient.grantRole(guildId, userId, roleId);
|
|
319
|
+
}
|
|
320
|
+
// 撤销角色
|
|
321
|
+
async revokeRole(guildId, userId, roleId) {
|
|
322
|
+
return this.httpClient.revokeRole(guildId, userId, roleId);
|
|
323
|
+
}
|
|
324
|
+
// ========== 频道管理方法 ==========
|
|
325
|
+
// 创建频道
|
|
326
|
+
async createChannel(guildId, name, options) {
|
|
327
|
+
return this.httpClient.createChannel(guildId, name, options);
|
|
328
|
+
}
|
|
329
|
+
// 更新频道
|
|
330
|
+
async updateChannel(channelId, options) {
|
|
331
|
+
return this.httpClient.updateChannel(channelId, options);
|
|
332
|
+
}
|
|
333
|
+
// 删除频道
|
|
334
|
+
async deleteChannel(channelId) {
|
|
335
|
+
return this.httpClient.deleteChannel(channelId);
|
|
336
|
+
}
|
|
337
|
+
// ========== 文件上传方法 ==========
|
|
338
|
+
// 上传文件/图片/视频
|
|
339
|
+
async uploadFile(file, options) {
|
|
340
|
+
return this.httpClient.uploadAsset(file, options);
|
|
341
|
+
}
|
|
342
|
+
// 上传并发送图片
|
|
343
|
+
async uploadAndSendImage(channelId, file, options) {
|
|
344
|
+
const { url } = await this.uploadFile(file, { filename: options?.filename });
|
|
345
|
+
return this.sendImageMessage(channelId, url, { quote: options?.quote });
|
|
346
|
+
}
|
|
347
|
+
// 上传并发送文件
|
|
348
|
+
async uploadAndSendFile(channelId, file, options) {
|
|
349
|
+
const { url } = await this.uploadFile(file, { filename: options?.filename });
|
|
350
|
+
return this.sendFileMessage(channelId, url, { quote: options?.quote });
|
|
351
|
+
}
|
|
352
|
+
// 上传并发送视频
|
|
353
|
+
async uploadAndSendVideo(channelId, file, options) {
|
|
354
|
+
const { url } = await this.uploadFile(file, { filename: options?.filename });
|
|
355
|
+
return this.sendVideoMessage(channelId, url, { quote: options?.quote });
|
|
356
|
+
}
|
|
357
|
+
// ========== 消息置顶方法 ==========
|
|
358
|
+
// 置顶消息
|
|
359
|
+
async pinMessage(msgId) {
|
|
360
|
+
return this.httpClient.pinMessage(msgId);
|
|
361
|
+
}
|
|
362
|
+
// 取消置顶消息
|
|
363
|
+
async unpinMessage(msgId) {
|
|
364
|
+
return this.httpClient.unpinMessage(msgId);
|
|
365
|
+
}
|
|
366
|
+
// ========== 语音频道方法 ==========
|
|
367
|
+
// 加入语音频道
|
|
368
|
+
async joinVoiceChannel(channelId, options) {
|
|
369
|
+
return this.httpClient.joinVoiceChannel(channelId, options);
|
|
370
|
+
}
|
|
371
|
+
// 离开语音频道
|
|
372
|
+
async leaveVoiceChannel(channelId) {
|
|
373
|
+
return this.httpClient.leaveVoiceChannel(channelId);
|
|
374
|
+
}
|
|
375
|
+
// 获取机器人加入的语音频道列表
|
|
376
|
+
async getVoiceChannels() {
|
|
377
|
+
return this.httpClient.getVoiceChannels();
|
|
378
|
+
}
|
|
379
|
+
// 保持语音连接活跃
|
|
380
|
+
async keepVoiceAlive(channelId) {
|
|
381
|
+
return this.httpClient.keepVoiceAlive(channelId);
|
|
382
|
+
}
|
|
383
|
+
// ========== 邀请相关方法 ==========
|
|
384
|
+
// 获取邀请列表
|
|
385
|
+
async getInvites(guildId) {
|
|
386
|
+
return this.httpClient.getInvites(guildId);
|
|
387
|
+
}
|
|
388
|
+
// 创建邀请链接
|
|
389
|
+
async createInvite(channelId, options) {
|
|
390
|
+
return this.httpClient.createInvite(channelId, options);
|
|
391
|
+
}
|
|
392
|
+
// 删除邀请链接
|
|
393
|
+
async deleteInvite(urlCode, guildId) {
|
|
394
|
+
return this.httpClient.deleteInvite(urlCode, guildId);
|
|
395
|
+
}
|
|
396
|
+
// ========== 黑名单相关方法 ==========
|
|
397
|
+
// 获取黑名单列表
|
|
398
|
+
async getBlacklist(guildId, options) {
|
|
399
|
+
return this.httpClient.getBlacklist(guildId, options);
|
|
400
|
+
}
|
|
401
|
+
// 添加黑名单
|
|
402
|
+
async addBlacklist(guildId, targetId, options) {
|
|
403
|
+
return this.httpClient.addBlacklist(guildId, targetId, options);
|
|
404
|
+
}
|
|
405
|
+
// 移除黑名单
|
|
406
|
+
async removeBlacklist(guildId, targetId) {
|
|
407
|
+
return this.httpClient.removeBlacklist(guildId, targetId);
|
|
408
|
+
}
|
|
409
|
+
// ========== 静音/闭麦相关方法 ==========
|
|
410
|
+
// 获取静音/闭麦列表
|
|
411
|
+
async getMuteList(guildId) {
|
|
412
|
+
return this.httpClient.getMuteList(guildId);
|
|
413
|
+
}
|
|
414
|
+
// 添加静音/闭麦
|
|
415
|
+
async addMute(guildId, targetId, type) {
|
|
416
|
+
return this.httpClient.addMute(guildId, targetId, type);
|
|
417
|
+
}
|
|
418
|
+
// 移除静音/闭麦
|
|
419
|
+
async removeMute(guildId, targetId, type) {
|
|
420
|
+
return this.httpClient.removeMute(guildId, targetId, type);
|
|
421
|
+
}
|
|
422
|
+
// ========== 助力相关方法 ==========
|
|
423
|
+
// 获取助力列表
|
|
424
|
+
async getBoosts(guildId) {
|
|
425
|
+
return this.httpClient.getBoosts(guildId);
|
|
426
|
+
}
|
|
427
|
+
// 获取助力历史
|
|
428
|
+
async getBoostHistory(guildId, options) {
|
|
429
|
+
return this.httpClient.getBoostHistory(guildId, options);
|
|
430
|
+
}
|
|
431
|
+
// ========== 服务器表情相关方法 ==========
|
|
432
|
+
// 获取服务器表情列表
|
|
433
|
+
async getGuildEmojis(guildId) {
|
|
434
|
+
return this.httpClient.getGuildEmojis(guildId);
|
|
435
|
+
}
|
|
436
|
+
// 创建服务器表情
|
|
437
|
+
async createGuildEmoji(guildId, name, emoji) {
|
|
438
|
+
return this.httpClient.createGuildEmoji(guildId, name, emoji);
|
|
439
|
+
}
|
|
440
|
+
// 更新服务器表情
|
|
441
|
+
async updateGuildEmoji(guildId, emojiId, name) {
|
|
442
|
+
return this.httpClient.updateGuildEmoji(guildId, emojiId, name);
|
|
443
|
+
}
|
|
444
|
+
// 删除服务器表情
|
|
445
|
+
async deleteGuildEmoji(guildId, emojiId) {
|
|
446
|
+
return this.httpClient.deleteGuildEmoji(guildId, emojiId);
|
|
447
|
+
}
|
|
448
|
+
// ========== 公告相关方法 ==========
|
|
449
|
+
// 获取公告列表
|
|
450
|
+
async getAnnouncements(guildId, options) {
|
|
451
|
+
return this.httpClient.getAnnouncements(guildId, options);
|
|
452
|
+
}
|
|
453
|
+
// 创建公告
|
|
454
|
+
async createAnnouncement(guildId, channelId, content) {
|
|
455
|
+
return this.httpClient.createAnnouncement(guildId, channelId, content);
|
|
456
|
+
}
|
|
457
|
+
// 更新公告
|
|
458
|
+
async updateAnnouncement(announcementId, content) {
|
|
459
|
+
return this.httpClient.updateAnnouncement(announcementId, content);
|
|
460
|
+
}
|
|
461
|
+
// 删除公告
|
|
462
|
+
async deleteAnnouncement(announcementId) {
|
|
463
|
+
return this.httpClient.deleteAnnouncement(announcementId);
|
|
464
|
+
}
|
|
465
|
+
// ========== 积分相关方法 ==========
|
|
466
|
+
// 获取积分排行
|
|
467
|
+
async getIntimacyRank(guildId, options) {
|
|
468
|
+
return this.httpClient.getIntimacyRank(guildId, options);
|
|
469
|
+
}
|
|
470
|
+
// 获取用户积分信息
|
|
471
|
+
async getIntimacyInfo(userId, guildId) {
|
|
472
|
+
return this.httpClient.getIntimacyInfo(userId, guildId);
|
|
473
|
+
}
|
|
474
|
+
// 更新用户积分
|
|
475
|
+
async updateIntimacy(userId, guildId, score) {
|
|
476
|
+
return this.httpClient.updateIntimacy(userId, guildId, score);
|
|
477
|
+
}
|
|
478
|
+
// ========== 游戏相关方法 ==========
|
|
479
|
+
// 获取游戏列表
|
|
480
|
+
async getGames() {
|
|
481
|
+
return this.httpClient.getGames();
|
|
482
|
+
}
|
|
483
|
+
// 创建游戏
|
|
484
|
+
async createGame(name, icon, options) {
|
|
485
|
+
return this.httpClient.createGame(name, icon, options);
|
|
486
|
+
}
|
|
487
|
+
// 更新游戏
|
|
488
|
+
async updateGame(gameId, options) {
|
|
489
|
+
return this.httpClient.updateGame(gameId, options);
|
|
490
|
+
}
|
|
491
|
+
// 删除游戏
|
|
492
|
+
async deleteGame(gameId) {
|
|
493
|
+
return this.httpClient.deleteGame(gameId);
|
|
494
|
+
}
|
|
495
|
+
// 开始玩游戏
|
|
496
|
+
async startPlaying(gameId) {
|
|
497
|
+
return this.httpClient.startPlaying(gameId);
|
|
498
|
+
}
|
|
499
|
+
// 结束玩游戏
|
|
500
|
+
async stopPlaying(gameId) {
|
|
501
|
+
return this.httpClient.stopPlaying(gameId);
|
|
502
|
+
}
|
|
503
|
+
// ========== 徽章相关方法 ==========
|
|
504
|
+
// 获取徽章列表
|
|
505
|
+
async getBadges(guildId) {
|
|
506
|
+
return this.httpClient.getBadges(guildId);
|
|
507
|
+
}
|
|
508
|
+
// 创建徽章
|
|
509
|
+
async createBadge(guildId, name, icon, options) {
|
|
510
|
+
return this.httpClient.createBadge(guildId, name, icon, options);
|
|
511
|
+
}
|
|
512
|
+
// 更新徽章
|
|
513
|
+
async updateBadge(badgeId, options) {
|
|
514
|
+
return this.httpClient.updateBadge(badgeId, options);
|
|
515
|
+
}
|
|
516
|
+
// 删除徽章
|
|
517
|
+
async deleteBadge(badgeId) {
|
|
518
|
+
return this.httpClient.deleteBadge(badgeId);
|
|
519
|
+
}
|
|
520
|
+
// 授予用户徽章
|
|
521
|
+
async grantBadge(guildId, userId, badgeId) {
|
|
522
|
+
return this.httpClient.grantBadge(guildId, userId, badgeId);
|
|
523
|
+
}
|
|
524
|
+
// 撤销用户徽章
|
|
525
|
+
async revokeBadge(guildId, userId, badgeId) {
|
|
526
|
+
return this.httpClient.revokeBadge(guildId, userId, badgeId);
|
|
527
|
+
}
|
|
528
|
+
// ========== 日程相关方法 ==========
|
|
529
|
+
// 获取日程列表
|
|
530
|
+
async getSchedules(channelId, options) {
|
|
531
|
+
return this.httpClient.getSchedules(channelId, options);
|
|
532
|
+
}
|
|
533
|
+
// 获取日程详情
|
|
534
|
+
async getSchedule(scheduleId) {
|
|
535
|
+
return this.httpClient.getSchedule(scheduleId);
|
|
536
|
+
}
|
|
537
|
+
// 创建日程
|
|
538
|
+
async createSchedule(channelId, title, startTime, endTime, options) {
|
|
539
|
+
return this.httpClient.createSchedule(channelId, title, startTime, endTime, options);
|
|
540
|
+
}
|
|
541
|
+
// 更新日程
|
|
542
|
+
async updateSchedule(scheduleId, options) {
|
|
543
|
+
return this.httpClient.updateSchedule(scheduleId, options);
|
|
544
|
+
}
|
|
545
|
+
// 删除日程
|
|
546
|
+
async deleteSchedule(scheduleId) {
|
|
547
|
+
return this.httpClient.deleteSchedule(scheduleId);
|
|
548
|
+
}
|
|
549
|
+
// ========== 频道分组相关方法 ==========
|
|
550
|
+
// 获取频道分组列表
|
|
551
|
+
async getChannelCategories(guildId) {
|
|
552
|
+
return this.httpClient.getChannelCategories(guildId);
|
|
553
|
+
}
|
|
554
|
+
// 创建频道分组
|
|
555
|
+
async createChannelCategory(guildId, name) {
|
|
556
|
+
return this.httpClient.createChannelCategory(guildId, name);
|
|
557
|
+
}
|
|
558
|
+
// 更新频道分组
|
|
559
|
+
async updateChannelCategory(categoryId, name) {
|
|
560
|
+
return this.httpClient.updateChannelCategory(categoryId, name);
|
|
561
|
+
}
|
|
562
|
+
// 删除频道分组
|
|
563
|
+
async deleteChannelCategory(categoryId) {
|
|
564
|
+
return this.httpClient.deleteChannelCategory(categoryId);
|
|
565
|
+
}
|
|
566
|
+
// 移动频道到分组
|
|
567
|
+
async moveChannelToCategory(channelId, parentId) {
|
|
568
|
+
return this.httpClient.moveChannelToCategory(channelId, parentId);
|
|
569
|
+
}
|
|
570
|
+
// ========== 用户聊天相关方法 ==========
|
|
571
|
+
// 获取用户聊天会话列表
|
|
572
|
+
async getUserChats() {
|
|
573
|
+
return this.httpClient.getUserChats();
|
|
574
|
+
}
|
|
575
|
+
// 获取用户聊天会话详情
|
|
576
|
+
async getUserChat(chatId) {
|
|
577
|
+
return this.httpClient.getUserChat(chatId);
|
|
578
|
+
}
|
|
579
|
+
// 创建用户聊天会话
|
|
580
|
+
async createUserChat(targetId) {
|
|
581
|
+
return this.httpClient.createUserChat(targetId);
|
|
582
|
+
}
|
|
583
|
+
// 删除用户聊天会话
|
|
584
|
+
async deleteUserChat(chatId) {
|
|
585
|
+
return this.httpClient.deleteUserChat(chatId);
|
|
586
|
+
}
|
|
587
|
+
// ========== 频道角色权限相关方法 ==========
|
|
588
|
+
// 获取频道角色权限列表
|
|
589
|
+
async getChannelRolePermissions(channelId) {
|
|
590
|
+
return this.httpClient.getChannelRolePermissions(channelId);
|
|
591
|
+
}
|
|
592
|
+
// 创建频道角色权限
|
|
593
|
+
async createChannelRolePermission(channelId, roleId, allow, deny) {
|
|
594
|
+
return this.httpClient.createChannelRolePermission(channelId, roleId, allow, deny);
|
|
595
|
+
}
|
|
596
|
+
// 更新频道角色权限
|
|
597
|
+
async updateChannelRolePermission(channelId, roleId, allow, deny) {
|
|
598
|
+
return this.httpClient.updateChannelRolePermission(channelId, roleId, allow, deny);
|
|
599
|
+
}
|
|
600
|
+
// 删除频道角色权限
|
|
601
|
+
async deleteChannelRolePermission(channelId, roleId) {
|
|
602
|
+
return this.httpClient.deleteChannelRolePermission(channelId, roleId);
|
|
603
|
+
}
|
|
604
|
+
// ========== 频道用户权限相关方法 ==========
|
|
605
|
+
// 获取频道用户权限列表
|
|
606
|
+
async getChannelUserPermissions(channelId) {
|
|
607
|
+
return this.httpClient.getChannelUserPermissions(channelId);
|
|
608
|
+
}
|
|
609
|
+
// 创建频道用户权限
|
|
610
|
+
async createChannelUserPermission(channelId, userId, allow, deny) {
|
|
611
|
+
return this.httpClient.createChannelUserPermission(channelId, userId, allow, deny);
|
|
612
|
+
}
|
|
613
|
+
// 更新频道用户权限
|
|
614
|
+
async updateChannelUserPermission(channelId, userId, allow, deny) {
|
|
615
|
+
return this.httpClient.updateChannelUserPermission(channelId, userId, allow, deny);
|
|
616
|
+
}
|
|
617
|
+
// 删除频道用户权限
|
|
618
|
+
async deleteChannelUserPermission(channelId, userId) {
|
|
619
|
+
return this.httpClient.deleteChannelUserPermission(channelId, userId);
|
|
620
|
+
}
|
|
621
|
+
// ========== 服务器打卡相关方法 ==========
|
|
622
|
+
// 获取服务器打卡信息
|
|
623
|
+
async getPunchIn(guildId) {
|
|
624
|
+
return this.httpClient.getPunchIn(guildId);
|
|
625
|
+
}
|
|
626
|
+
// 服务器打卡
|
|
627
|
+
async punchIn(guildId) {
|
|
628
|
+
return this.httpClient.punchIn(guildId);
|
|
629
|
+
}
|
|
630
|
+
// ========== 批量相关方法 ==========
|
|
631
|
+
// 批量获取用户信息
|
|
632
|
+
async getUsersBatch(userIds) {
|
|
633
|
+
return this.httpClient.getUsersBatch(userIds);
|
|
634
|
+
}
|
|
635
|
+
// 批量获取服务器信息
|
|
636
|
+
async getGuildsBatch(guildIds) {
|
|
637
|
+
return this.httpClient.getGuildsBatch(guildIds);
|
|
638
|
+
}
|
|
639
|
+
// ========== 服务器设置相关方法 ==========
|
|
640
|
+
// 获取服务器设置
|
|
641
|
+
async getGuildSettings(guildId) {
|
|
642
|
+
return this.httpClient.getGuildSettings(guildId);
|
|
643
|
+
}
|
|
644
|
+
// ========== 网关相关方法 ==========
|
|
645
|
+
// 获取网关连接地址
|
|
646
|
+
async getGateway(compress) {
|
|
647
|
+
return this.httpClient.getGateway(compress);
|
|
648
|
+
}
|
|
649
|
+
// ========== 服务器欢迎设置相关方法 ==========
|
|
650
|
+
async getGuildWelcome(guildId) {
|
|
651
|
+
return this.httpClient.getGuildWelcome(guildId);
|
|
652
|
+
}
|
|
653
|
+
async updateGuildWelcome(guildId, options) {
|
|
654
|
+
return this.httpClient.updateGuildWelcome(guildId, options);
|
|
655
|
+
}
|
|
656
|
+
// ========== 服务器通知设置相关方法 ==========
|
|
657
|
+
async getGuildNotify(guildId) {
|
|
658
|
+
return this.httpClient.getGuildNotify(guildId);
|
|
659
|
+
}
|
|
660
|
+
async updateGuildNotify(guildId, notifyType) {
|
|
661
|
+
return this.httpClient.updateGuildNotify(guildId, notifyType);
|
|
662
|
+
}
|
|
663
|
+
// ========== 私聊消息相关扩展方法 ==========
|
|
664
|
+
async getDirectMessageDetail(msgId) {
|
|
665
|
+
return this.httpClient.getDirectMessageDetail(msgId);
|
|
666
|
+
}
|
|
667
|
+
async updateDirectMessage(msgId, content, options) {
|
|
668
|
+
return this.httpClient.updateDirectMessage(msgId, content, options);
|
|
669
|
+
}
|
|
670
|
+
async deleteDirectMessage(msgId) {
|
|
671
|
+
return this.httpClient.deleteDirectMessage(msgId);
|
|
672
|
+
}
|
|
673
|
+
// ========== 消息相关扩展方法 ==========
|
|
674
|
+
async addMessageReadReceipt(msgId) {
|
|
675
|
+
return this.httpClient.addMessageReadReceipt(msgId);
|
|
676
|
+
}
|
|
677
|
+
async getMessageReadReceipts(msgId) {
|
|
678
|
+
return this.httpClient.getMessageReadReceipts(msgId);
|
|
679
|
+
}
|
|
680
|
+
// ========== 频道相关扩展方法 ==========
|
|
681
|
+
async setVoiceQuality(channelId, quality) {
|
|
682
|
+
return this.httpClient.setVoiceQuality(channelId, quality);
|
|
683
|
+
}
|
|
684
|
+
async setSlowMode(channelId, slowMode) {
|
|
685
|
+
return this.httpClient.setSlowMode(channelId, slowMode);
|
|
686
|
+
}
|
|
687
|
+
// ========== 服务器角色权限相关扩展方法 ==========
|
|
688
|
+
async batchUpdateGuildRolePermissions(guildId, permissions) {
|
|
689
|
+
return this.httpClient.batchUpdateGuildRolePermissions(guildId, permissions);
|
|
690
|
+
}
|
|
691
|
+
// ========== 用户相关扩展方法 ==========
|
|
692
|
+
async getFriends() {
|
|
693
|
+
return this.httpClient.getFriends();
|
|
694
|
+
}
|
|
695
|
+
async getFriendRequests() {
|
|
696
|
+
return this.httpClient.getFriendRequests();
|
|
697
|
+
}
|
|
698
|
+
async sendFriendRequest(targetId, content) {
|
|
699
|
+
return this.httpClient.sendFriendRequest(targetId, content);
|
|
700
|
+
}
|
|
701
|
+
async acceptFriendRequest(targetId) {
|
|
702
|
+
return this.httpClient.acceptFriendRequest(targetId);
|
|
703
|
+
}
|
|
704
|
+
async declineFriendRequest(targetId) {
|
|
705
|
+
return this.httpClient.declineFriendRequest(targetId);
|
|
706
|
+
}
|
|
707
|
+
async deleteFriend(targetId) {
|
|
708
|
+
return this.httpClient.deleteFriend(targetId);
|
|
709
|
+
}
|
|
710
|
+
// ========== 服务器成员相关扩展方法 ==========
|
|
711
|
+
async getGuildMemberOnlineStatus(guildId, userId) {
|
|
712
|
+
return this.httpClient.getGuildMemberOnlineStatus(guildId, userId);
|
|
713
|
+
}
|
|
714
|
+
async getGuildMemberPermissions(guildId, userId) {
|
|
715
|
+
return this.httpClient.getGuildMemberPermissions(guildId, userId);
|
|
716
|
+
}
|
|
717
|
+
// ========== 批量操作相关扩展方法 ==========
|
|
718
|
+
async getChannelsBatch(channelIds) {
|
|
719
|
+
return this.httpClient.getChannelsBatch(channelIds);
|
|
720
|
+
}
|
|
721
|
+
async getMessagesBatch(msgIds) {
|
|
722
|
+
return this.httpClient.getMessagesBatch(msgIds);
|
|
723
|
+
}
|
|
724
|
+
// ========== 工具方法 ==========
|
|
725
|
+
// 获取运行状态
|
|
726
|
+
get running() {
|
|
727
|
+
return this.isRunning;
|
|
728
|
+
}
|
|
729
|
+
// 获取 WebSocket 连接状态
|
|
730
|
+
get connected() {
|
|
731
|
+
return this.wsClient?.isConnected ?? false;
|
|
732
|
+
}
|
|
733
|
+
// 获取 HTTP 客户端
|
|
734
|
+
get http() {
|
|
735
|
+
return this.httpClient;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
exports.KookBot = KookBot;
|
|
739
|
+
//# sourceMappingURL=bot.js.map
|