@alemonjs/kook 2.1.0-alpha.3 → 2.1.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/lib/config.d.ts +4 -5
- package/lib/config.js +1 -1
- package/lib/core/config.d.ts +8 -0
- package/lib/core/config.js +0 -23
- package/lib/desktop.d.ts +1 -3
- package/lib/desktop.js +0 -9
- package/lib/hook.d.ts +7 -19
- package/lib/hook.js +0 -10
- package/lib/index.d.ts +5 -6
- package/lib/index.js +396 -242
- package/lib/sdk/api.d.ts +3 -117
- package/lib/sdk/api.js +0 -112
- package/lib/sdk/config.d.ts +4 -0
- package/lib/sdk/conversation.d.ts +35 -0
- package/lib/sdk/conversation.js +24 -49
- package/lib/sdk/index.d.ts +2 -0
- package/lib/sdk/index.js +2 -0
- package/lib/sdk/instance.d.ts +3 -0
- package/lib/sdk/instance.js +12 -28
- package/lib/sdk/message/INTERACTION.d.ts +2 -0
- package/lib/sdk/message/INTERACTION.js +1 -0
- package/lib/sdk/message/MEMBER_ADD.d.ts +2 -0
- package/lib/sdk/message/MEMBER_ADD.js +1 -0
- package/lib/sdk/message/MEMBER_REMOVE.d.ts +2 -0
- package/lib/sdk/message/MEMBER_REMOVE.js +1 -0
- package/lib/sdk/message/MESSAGES_DIRECT.d.ts +2 -0
- package/lib/sdk/message/MESSAGES_DIRECT.js +1 -0
- package/lib/sdk/message/MESSAGES_PUBLIC.d.ts +2 -0
- package/lib/sdk/message/MESSAGES_PUBLIC.js +1 -0
- package/lib/sdk/message/REACTIONS.d.ts +2 -0
- package/lib/sdk/message/REACTIONS.js +1 -0
- package/lib/sdk/message.d.ts +40 -0
- package/lib/sdk/message.js +11 -7
- package/lib/sdk/typings.d.ts +192 -43
- package/lib/sdk/typings.js +19 -89
- package/lib/sdk/wss.d.ts +9 -0
- package/lib/sdk/wss.js +23 -40
- package/lib/sdk/wss.types.d.ts +3 -0
- package/lib/sdk/wss.types.js +1 -0
- package/package.json +3 -3
package/lib/sdk/instance.js
CHANGED
|
@@ -6,17 +6,14 @@ const filterHeaders = (headers = {}) => {
|
|
|
6
6
|
const sensitiveKeys = [/^authorization$/i, /^cookie$/i, /^set-cookie$/i, /token/i, /key/i, /jwt/i, /^session[-_]id$/i, /^uid$/i, /^user[-_]id$/i];
|
|
7
7
|
for (const key in headers) {
|
|
8
8
|
if (/^_/.test(key)) {
|
|
9
|
-
continue;
|
|
9
|
+
continue;
|
|
10
10
|
}
|
|
11
|
-
// 去掉 Symbol 类型的 key
|
|
12
11
|
if (typeof key === 'symbol') {
|
|
13
12
|
continue;
|
|
14
13
|
}
|
|
15
|
-
// 去掉函数
|
|
16
14
|
if (typeof headers[key] === 'function') {
|
|
17
15
|
continue;
|
|
18
16
|
}
|
|
19
|
-
// 如果是敏感字段全部替换为 ******
|
|
20
17
|
if (sensitiveKeys.some(re => re.test(key))) {
|
|
21
18
|
filtered[key] = '******';
|
|
22
19
|
}
|
|
@@ -33,13 +30,11 @@ const filterConfig = (config = {}) => {
|
|
|
33
30
|
const filtered = {};
|
|
34
31
|
for (const key in config) {
|
|
35
32
|
if (/^_/.test(key)) {
|
|
36
|
-
continue;
|
|
33
|
+
continue;
|
|
37
34
|
}
|
|
38
|
-
// 去掉 Symbol 类型的 key
|
|
39
35
|
if (typeof key === 'symbol') {
|
|
40
36
|
continue;
|
|
41
37
|
}
|
|
42
|
-
// 去掉函数
|
|
43
38
|
if (typeof config[key] === 'function') {
|
|
44
39
|
continue;
|
|
45
40
|
}
|
|
@@ -54,13 +49,11 @@ const filterRequest = (request = {}) => {
|
|
|
54
49
|
const filtered = {};
|
|
55
50
|
for (const key in request) {
|
|
56
51
|
if (/^_/.test(key)) {
|
|
57
|
-
continue;
|
|
52
|
+
continue;
|
|
58
53
|
}
|
|
59
|
-
// 去掉 Symbol 类型的 key
|
|
60
54
|
if (typeof key === 'symbol') {
|
|
61
55
|
continue;
|
|
62
56
|
}
|
|
63
|
-
// 去掉函数
|
|
64
57
|
if (typeof request[key] === 'function') {
|
|
65
58
|
continue;
|
|
66
59
|
}
|
|
@@ -68,9 +61,7 @@ const filterRequest = (request = {}) => {
|
|
|
68
61
|
}
|
|
69
62
|
return filtered;
|
|
70
63
|
};
|
|
71
|
-
// 处理axios错误
|
|
72
64
|
const loggerError = err => {
|
|
73
|
-
// 错误时的请求头
|
|
74
65
|
logger.error('[axios] error', {
|
|
75
66
|
config: {
|
|
76
67
|
headers: filterHeaders(err?.config?.headers),
|
|
@@ -88,22 +79,15 @@ const loggerError = err => {
|
|
|
88
79
|
message: err?.message
|
|
89
80
|
});
|
|
90
81
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
.then(res => resolve(res?.data ?? {}))
|
|
101
|
-
.catch(err => {
|
|
102
|
-
loggerError(err);
|
|
103
|
-
// 丢出错误中携带的响应数据
|
|
104
|
-
reject(err?.response?.data);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
82
|
+
const createAxiosInstance = async (service, options) => {
|
|
83
|
+
try {
|
|
84
|
+
const res = await service(options);
|
|
85
|
+
return res?.data ?? {};
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
loggerError(err);
|
|
89
|
+
throw err?.response?.data ?? err;
|
|
90
|
+
}
|
|
107
91
|
};
|
|
108
92
|
|
|
109
93
|
export { createAxiosInstance };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { MEMBER_ADD_TYPE } from './message/MEMBER_ADD';
|
|
2
|
+
import { MEMBER_REMOVE_TYPE } from './message/MEMBER_REMOVE';
|
|
3
|
+
import { INTERACTION_TYPE } from './message/INTERACTION';
|
|
4
|
+
import { MESSAGES_DIRECT_TYPE } from './message/MESSAGES_DIRECT';
|
|
5
|
+
import { MESSAGES_PUBLIC_TYPE } from './message/MESSAGES_PUBLIC';
|
|
6
|
+
import { REACTIONS_TYPE } from './message/REACTIONS';
|
|
7
|
+
export declare const KOOKEventKey: {
|
|
8
|
+
MEMBER_ADD: string;
|
|
9
|
+
MEMBER_REMOVE: string;
|
|
10
|
+
INTERACTION: string;
|
|
11
|
+
MESSAGES_DIRECT: string;
|
|
12
|
+
MESSAGES_PUBLIC: string;
|
|
13
|
+
REACTIONS: string;
|
|
14
|
+
MESSAGES_UPDATE: string;
|
|
15
|
+
MESSAGES_DELETE: string;
|
|
16
|
+
MESSAGES_PIN: string;
|
|
17
|
+
CHANNEL_CREATE: string;
|
|
18
|
+
CHANNEL_DELETE: string;
|
|
19
|
+
CHANNEL_UPDATE: string;
|
|
20
|
+
GUILD_JOIN: string;
|
|
21
|
+
GUILD_EXIT: string;
|
|
22
|
+
ERROR: string;
|
|
23
|
+
};
|
|
24
|
+
export type KOOKEventMap = {
|
|
25
|
+
MEMBER_ADD: MEMBER_ADD_TYPE;
|
|
26
|
+
MEMBER_REMOVE: MEMBER_REMOVE_TYPE;
|
|
27
|
+
INTERACTION: INTERACTION_TYPE;
|
|
28
|
+
MESSAGES_DIRECT: MESSAGES_DIRECT_TYPE;
|
|
29
|
+
MESSAGES_PUBLIC: MESSAGES_PUBLIC_TYPE;
|
|
30
|
+
REACTIONS: REACTIONS_TYPE;
|
|
31
|
+
MESSAGES_UPDATE: any;
|
|
32
|
+
MESSAGES_DELETE: any;
|
|
33
|
+
MESSAGES_PIN: any;
|
|
34
|
+
CHANNEL_CREATE: any;
|
|
35
|
+
CHANNEL_DELETE: any;
|
|
36
|
+
CHANNEL_UPDATE: any;
|
|
37
|
+
GUILD_JOIN: any;
|
|
38
|
+
GUILD_EXIT: any;
|
|
39
|
+
ERROR: any;
|
|
40
|
+
};
|
package/lib/sdk/message.js
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
const KOOKEventKey = {
|
|
2
|
-
// 成员加入
|
|
3
2
|
MEMBER_ADD: 'MEMBER_ADD',
|
|
4
|
-
// 成员退出
|
|
5
3
|
MEMBER_REMOVE: 'MEMBER_REMOVE',
|
|
6
|
-
// 交互
|
|
7
4
|
INTERACTION: 'INTERACTION',
|
|
8
|
-
// 私聊消息
|
|
9
5
|
MESSAGES_DIRECT: 'MESSAGES_DIRECT',
|
|
10
|
-
// 频道消息
|
|
11
6
|
MESSAGES_PUBLIC: 'MESSAGES_PUBLIC',
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
REACTIONS: 'REACTIONS',
|
|
8
|
+
MESSAGES_UPDATE: 'MESSAGES_UPDATE',
|
|
9
|
+
MESSAGES_DELETE: 'MESSAGES_DELETE',
|
|
10
|
+
MESSAGES_PIN: 'MESSAGES_PIN',
|
|
11
|
+
CHANNEL_CREATE: 'CHANNEL_CREATE',
|
|
12
|
+
CHANNEL_DELETE: 'CHANNEL_DELETE',
|
|
13
|
+
CHANNEL_UPDATE: 'CHANNEL_UPDATE',
|
|
14
|
+
GUILD_JOIN: 'GUILD_JOIN',
|
|
15
|
+
GUILD_EXIT: 'GUILD_EXIT',
|
|
16
|
+
ERROR: 'ERROR'
|
|
17
|
+
};
|
|
14
18
|
|
|
15
19
|
export { KOOKEventKey };
|
package/lib/sdk/typings.d.ts
CHANGED
|
@@ -1,12 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export declare enum ApiEnum {
|
|
2
|
+
GuildList = "/api/v3/guild/list",
|
|
3
|
+
GuildView = "/api/v3/guild/view",
|
|
4
|
+
GuildUserList = "/api/v3/guild/user-list",
|
|
5
|
+
GuildNickname = "/api/v3/guild/nickname",
|
|
6
|
+
GuildLeave = "/api/v3/guild/leave",
|
|
7
|
+
GuildKickout = "/api/v3/guild/kickout",
|
|
8
|
+
GuildMuteList = "/api/v3/guild-mute/list",
|
|
9
|
+
GuildMuteCreate = "/api/v3/guild-mute/create",
|
|
10
|
+
GuildMuteDelete = "/api/v3/guild-mute/delete",
|
|
11
|
+
GuildBoostHistory = "/api/v3/guild-boost/history",
|
|
12
|
+
ChannelMessage = "/api/v3/channel/message",
|
|
13
|
+
ChannelList = "/api/v3/channel/list",
|
|
14
|
+
ChannelView = "/api/v3/channel/view",
|
|
15
|
+
ChannelCreate = "/api/v3/channel/create",
|
|
16
|
+
ChannelUpdate = "/api/v3/channel/update",
|
|
17
|
+
ChannelDelete = "/api/v3/channel/delete",
|
|
18
|
+
ChannelUserList = "/api/v3/channel/user-list",
|
|
19
|
+
ChannelMoveUser = "/api/v3/channel/move-user",
|
|
20
|
+
ChannelRoleIndex = "/api/v3/channel-role/index",
|
|
21
|
+
ChannelRoleCreate = "/api/v3/channel-role/create",
|
|
22
|
+
ChannelRoleUpdate = "/api/v3/channel-role/update",
|
|
23
|
+
ChannelRoleSync = "/api/v3/channel-role/sync",
|
|
24
|
+
ChannelRoleDelete = "/api/v3/channel-role/delete",
|
|
25
|
+
MessageList = "/api/v3/message/list",
|
|
26
|
+
MessageView = "/api/v3/message/view",
|
|
27
|
+
MessageCreate = "/api/v3/message/create",
|
|
28
|
+
MessageUpdate = "/api/v3/message/update",
|
|
29
|
+
MessageDelete = "/api/v3/message/delete",
|
|
30
|
+
MessageReactionList = "/api/v3/message/reaction-list",
|
|
31
|
+
MessageAddReaction = "/api/v3/message/add-reaction",
|
|
32
|
+
MessageDeleteReaction = "/api/v3/message/delete-reaction",
|
|
33
|
+
GetJoinedChannel = "/api/v3/channel-user/get-joined-channel",
|
|
34
|
+
UserChatList = "/api/v3/user-chat/list",
|
|
35
|
+
UserChatView = "/api/v3/user-chat/view",
|
|
36
|
+
UserChatCreate = "/api/v3/user-chat/create",
|
|
37
|
+
UserChatDelete = "/api/v3/user-chat/delete",
|
|
38
|
+
DirectMessageList = "/api/v3/direct-message/list",
|
|
39
|
+
DirectMessageView = "/api/v3/direct-message/view",
|
|
40
|
+
DirectMessageCreate = "/api/v3/direct-message/create",
|
|
41
|
+
DirectMessageUpdate = "/api/v3/direct-message/update",
|
|
42
|
+
DirectMessageDelete = "/api/v3/direct-message/delete",
|
|
43
|
+
DirectMessageReactionList = "/api/v3/direct-message/reaction-list",
|
|
44
|
+
DirectMessageAddReaction = "/api/v3/direct-message/add-reaction",
|
|
45
|
+
DirectMessageDeleteReaction = "/api/v3/direct-message/delete-reaction",
|
|
46
|
+
UserMe = "/api/v3/user/me",
|
|
47
|
+
UserView = "/api/v3/user/view",
|
|
48
|
+
UserOffline = "/api/v3/user/offline",
|
|
49
|
+
AssetCreate = "/api/v3/asset/create",
|
|
50
|
+
GuildRoleList = "/api/v3/guild-role/list",
|
|
51
|
+
GuildRoleCreate = "/api/v3/guild-role/create",
|
|
52
|
+
GuildRoleUpdate = "/api/v3/guild-role/update",
|
|
53
|
+
GuildRoleDelete = "/api/v3/guild-role/delete",
|
|
54
|
+
GuildRoleGrant = "/api/v3/guild-role/grant",
|
|
55
|
+
GuildRoleRevoke = "/api/v3/guild-role/revoke",
|
|
56
|
+
IntimacyIndex = "/api/v3/intimacy/index",
|
|
57
|
+
IntimacyUpdate = "/api/v3/intimacy/update",
|
|
58
|
+
GuildEmojiList = "/api/v3/guild-emoji/list",
|
|
59
|
+
GuildEmojiCreate = "/api/v3/guild-emoji/create",
|
|
60
|
+
GuildEmojiUpdate = "/api/v3/guild-emoji/update",
|
|
61
|
+
GuildEmojiDelete = "/api/v3/guild-emoji/delete",
|
|
62
|
+
InviteList = "/api/v3/invite/list",
|
|
63
|
+
InviteCreate = "/api/v3/invite/create",
|
|
64
|
+
InviteDelete = "/api/v3/invite/delete",
|
|
65
|
+
BlacklistList = "/api/v3/blacklist/list",
|
|
66
|
+
BlacklistCreate = "/api/v3/blacklist/create",
|
|
67
|
+
BlacklistDelete = "/api/v3/blacklist/delete",
|
|
68
|
+
BadgeGuild = "/api/v3/badge/guild",
|
|
69
|
+
GameList = "/api/v3/game",
|
|
70
|
+
GameCreate = "/api/v3/game/create",
|
|
71
|
+
GameUpdate = "/api/v3/game/update",
|
|
72
|
+
GameDelete = "/api/v3/game/delete",
|
|
73
|
+
GameActivity = "/api/v3/game/activity",
|
|
74
|
+
GameDeleteActivity = "/api/v3/game/delete-activity",
|
|
75
|
+
OAuth2Token = "/api/oauth2/token",
|
|
76
|
+
GatewayIndex = "/api/v3/gateway/index"
|
|
77
|
+
}
|
|
78
|
+
export type MessageType = 1 | 2 | 3 | 4 | 8 | 9 | 10 | 255;
|
|
79
|
+
export type MessageChannelType = 'GROUP' | 'PERSON' | 'BROADCAST';
|
|
80
|
+
export interface EventData {
|
|
10
81
|
channel_type: MessageChannelType;
|
|
11
82
|
type: MessageType;
|
|
12
83
|
target_id: string;
|
|
@@ -18,33 +89,31 @@ interface EventData {
|
|
|
18
89
|
nonce: string;
|
|
19
90
|
from_type: number;
|
|
20
91
|
}
|
|
21
|
-
|
|
22
|
-
* 消息发送参数
|
|
23
|
-
*/
|
|
24
|
-
interface SendMessageParams {
|
|
25
|
-
/**
|
|
26
|
-
* 消息类型
|
|
27
|
-
*/
|
|
92
|
+
export interface SendMessageParams {
|
|
28
93
|
type?: number;
|
|
29
|
-
/**
|
|
30
|
-
* 频道编号
|
|
31
|
-
*/
|
|
32
94
|
target_id: string;
|
|
33
|
-
/**
|
|
34
|
-
* 消息内容
|
|
35
|
-
*/
|
|
36
95
|
content: string;
|
|
37
|
-
/**
|
|
38
|
-
* 引用--消息id
|
|
39
|
-
*/
|
|
40
96
|
quote?: string;
|
|
41
97
|
nonce?: string;
|
|
42
98
|
temp_target_id?: string;
|
|
43
99
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
100
|
+
export interface BotInformation {
|
|
101
|
+
id: string;
|
|
102
|
+
username: string;
|
|
103
|
+
identify_num: string;
|
|
104
|
+
online: boolean;
|
|
105
|
+
os: string;
|
|
106
|
+
status: number;
|
|
107
|
+
avatar: string;
|
|
108
|
+
banner: string;
|
|
109
|
+
bot: boolean;
|
|
110
|
+
mobile_verified: boolean;
|
|
111
|
+
client_id: string;
|
|
112
|
+
mobile_prefix: string;
|
|
113
|
+
mobile: string;
|
|
114
|
+
invited_count: number;
|
|
115
|
+
}
|
|
116
|
+
export interface Author {
|
|
48
117
|
id: string;
|
|
49
118
|
username: string;
|
|
50
119
|
identify_num: string;
|
|
@@ -64,19 +133,13 @@ interface Author {
|
|
|
64
133
|
decorations_id_map: null | unknown;
|
|
65
134
|
is_sys: boolean;
|
|
66
135
|
}
|
|
67
|
-
|
|
68
|
-
* mk接口
|
|
69
|
-
*/
|
|
70
|
-
interface KMarkdown {
|
|
136
|
+
export interface KMarkdown {
|
|
71
137
|
raw_content: string;
|
|
72
138
|
mention_part: any[];
|
|
73
139
|
mention_role_part: any[];
|
|
74
140
|
channel_part: any[];
|
|
75
141
|
}
|
|
76
|
-
|
|
77
|
-
* 数据包
|
|
78
|
-
*/
|
|
79
|
-
interface Extra {
|
|
142
|
+
export interface Extra {
|
|
80
143
|
type: number;
|
|
81
144
|
code: string;
|
|
82
145
|
guild_id: string;
|
|
@@ -94,10 +157,7 @@ interface Extra {
|
|
|
94
157
|
last_msg_content: string;
|
|
95
158
|
send_msg_device: number;
|
|
96
159
|
}
|
|
97
|
-
|
|
98
|
-
* 私聊消息
|
|
99
|
-
*/
|
|
100
|
-
interface SendDirectMessageParams {
|
|
160
|
+
export interface SendDirectMessageParams {
|
|
101
161
|
type?: MessageType;
|
|
102
162
|
target_id?: string;
|
|
103
163
|
chat_code?: string;
|
|
@@ -105,5 +165,94 @@ interface SendDirectMessageParams {
|
|
|
105
165
|
quote?: string;
|
|
106
166
|
nonce?: string;
|
|
107
167
|
}
|
|
108
|
-
|
|
109
|
-
|
|
168
|
+
export interface SystemData {
|
|
169
|
+
channel_type: MessageChannelType;
|
|
170
|
+
type: number;
|
|
171
|
+
target_id: string;
|
|
172
|
+
author_id: string;
|
|
173
|
+
content: string;
|
|
174
|
+
extra: {
|
|
175
|
+
type: (typeof SystemDataEnum)[number];
|
|
176
|
+
body: overheadData | memberData | ChannelData | StatementData | EditingData | OnLineData;
|
|
177
|
+
};
|
|
178
|
+
msg_id: string;
|
|
179
|
+
msg_timestamp: number;
|
|
180
|
+
nonce: string;
|
|
181
|
+
from_type: number;
|
|
182
|
+
}
|
|
183
|
+
export interface OnLineData {
|
|
184
|
+
user_id: string;
|
|
185
|
+
event_time: number;
|
|
186
|
+
guilds: any[];
|
|
187
|
+
}
|
|
188
|
+
export interface overheadData {
|
|
189
|
+
channel_id: string;
|
|
190
|
+
operator_id: string;
|
|
191
|
+
msg_id: string;
|
|
192
|
+
}
|
|
193
|
+
export interface memberData {
|
|
194
|
+
user_id: string;
|
|
195
|
+
exited_at: number;
|
|
196
|
+
}
|
|
197
|
+
export interface ChannelData {
|
|
198
|
+
id: string;
|
|
199
|
+
name: string;
|
|
200
|
+
user_id: string;
|
|
201
|
+
guild_id: string;
|
|
202
|
+
guild_type: number;
|
|
203
|
+
limit_amount: number;
|
|
204
|
+
is_category: number;
|
|
205
|
+
parent_id: string;
|
|
206
|
+
level: number;
|
|
207
|
+
slow_mode: number;
|
|
208
|
+
topic: string;
|
|
209
|
+
type: number;
|
|
210
|
+
permission_overwrites: any[];
|
|
211
|
+
permission_users: any[];
|
|
212
|
+
permission_sync: number;
|
|
213
|
+
mode: number;
|
|
214
|
+
has_password: boolean;
|
|
215
|
+
last_msg_content: string;
|
|
216
|
+
last_msg_id: string;
|
|
217
|
+
sync_guild_region: number;
|
|
218
|
+
region: string;
|
|
219
|
+
joined_at: number;
|
|
220
|
+
}
|
|
221
|
+
export interface StatementData {
|
|
222
|
+
channel_id: string;
|
|
223
|
+
emoji: {
|
|
224
|
+
[key: string]: any;
|
|
225
|
+
};
|
|
226
|
+
user_id: string;
|
|
227
|
+
msg_id: string;
|
|
228
|
+
}
|
|
229
|
+
export interface ButtonData {
|
|
230
|
+
channel_id: string;
|
|
231
|
+
target_id: string;
|
|
232
|
+
emoji: {
|
|
233
|
+
[key: string]: any;
|
|
234
|
+
};
|
|
235
|
+
user_id: string;
|
|
236
|
+
msg_id: string;
|
|
237
|
+
value: string;
|
|
238
|
+
}
|
|
239
|
+
export interface joinedData {
|
|
240
|
+
user_id: string;
|
|
241
|
+
joined_at: number;
|
|
242
|
+
}
|
|
243
|
+
export interface EditingData {
|
|
244
|
+
version_id: string;
|
|
245
|
+
channel_id: string;
|
|
246
|
+
target_id: string;
|
|
247
|
+
content: string;
|
|
248
|
+
mention: string[];
|
|
249
|
+
mention_all: boolean;
|
|
250
|
+
mention_here: boolean;
|
|
251
|
+
mention_roles: string[];
|
|
252
|
+
updated_at: number;
|
|
253
|
+
kmarkdown: any;
|
|
254
|
+
last_msg_content: string;
|
|
255
|
+
embeds: any[];
|
|
256
|
+
msg_id: string;
|
|
257
|
+
}
|
|
258
|
+
export declare const SystemDataEnum: readonly ["joined_guild", "exited_guild", "self_joined_guild", "self_exited_guild", "joined_channel", "exited_channel", "updated_channel", "added_channel", "deleted_channel", "pinned_message", "deleted_message", "guild_member_online", "added_reaction", "deleted_reaction", "updated_message", "message_btn_click"];
|
package/lib/sdk/typings.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* api枚举
|
|
3
|
-
*/
|
|
4
1
|
var ApiEnum;
|
|
5
2
|
(function (ApiEnum) {
|
|
6
|
-
/**
|
|
7
|
-
* ********
|
|
8
|
-
* 频道相关
|
|
9
|
-
* ********
|
|
10
|
-
*/
|
|
11
3
|
ApiEnum["GuildList"] = "/api/v3/guild/list";
|
|
12
4
|
ApiEnum["GuildView"] = "/api/v3/guild/view";
|
|
13
5
|
ApiEnum["GuildUserList"] = "/api/v3/guild/user-list";
|
|
@@ -18,11 +10,6 @@ var ApiEnum;
|
|
|
18
10
|
ApiEnum["GuildMuteCreate"] = "/api/v3/guild-mute/create";
|
|
19
11
|
ApiEnum["GuildMuteDelete"] = "/api/v3/guild-mute/delete";
|
|
20
12
|
ApiEnum["GuildBoostHistory"] = "/api/v3/guild-boost/history";
|
|
21
|
-
/**
|
|
22
|
-
* *******
|
|
23
|
-
* 子频道接口
|
|
24
|
-
* ******
|
|
25
|
-
*/
|
|
26
13
|
ApiEnum["ChannelMessage"] = "/api/v3/channel/message";
|
|
27
14
|
ApiEnum["ChannelList"] = "/api/v3/channel/list";
|
|
28
15
|
ApiEnum["ChannelView"] = "/api/v3/channel/view";
|
|
@@ -36,11 +23,6 @@ var ApiEnum;
|
|
|
36
23
|
ApiEnum["ChannelRoleUpdate"] = "/api/v3/channel-role/update";
|
|
37
24
|
ApiEnum["ChannelRoleSync"] = "/api/v3/channel-role/sync";
|
|
38
25
|
ApiEnum["ChannelRoleDelete"] = "/api/v3/channel-role/delete";
|
|
39
|
-
/**
|
|
40
|
-
* ******
|
|
41
|
-
* 消息接口
|
|
42
|
-
* ****
|
|
43
|
-
*/
|
|
44
26
|
ApiEnum["MessageList"] = "/api/v3/message/list";
|
|
45
27
|
ApiEnum["MessageView"] = "/api/v3/message/view";
|
|
46
28
|
ApiEnum["MessageCreate"] = "/api/v3/message/create";
|
|
@@ -49,26 +31,11 @@ var ApiEnum;
|
|
|
49
31
|
ApiEnum["MessageReactionList"] = "/api/v3/message/reaction-list";
|
|
50
32
|
ApiEnum["MessageAddReaction"] = "/api/v3/message/add-reaction";
|
|
51
33
|
ApiEnum["MessageDeleteReaction"] = "/api/v3/message/delete-reaction";
|
|
52
|
-
/**
|
|
53
|
-
* *******
|
|
54
|
-
* 频道用户
|
|
55
|
-
* *******
|
|
56
|
-
*/
|
|
57
34
|
ApiEnum["GetJoinedChannel"] = "/api/v3/channel-user/get-joined-channel";
|
|
58
|
-
/**
|
|
59
|
-
* *******
|
|
60
|
-
* 私聊会话
|
|
61
|
-
* *******
|
|
62
|
-
*/
|
|
63
35
|
ApiEnum["UserChatList"] = "/api/v3/user-chat/list";
|
|
64
36
|
ApiEnum["UserChatView"] = "/api/v3/user-chat/view";
|
|
65
37
|
ApiEnum["UserChatCreate"] = "/api/v3/user-chat/create";
|
|
66
38
|
ApiEnum["UserChatDelete"] = "/api/v3/user-chat/delete";
|
|
67
|
-
/**
|
|
68
|
-
* *******
|
|
69
|
-
* 用户私聊
|
|
70
|
-
* *******
|
|
71
|
-
*/
|
|
72
39
|
ApiEnum["DirectMessageList"] = "/api/v3/direct-message/list";
|
|
73
40
|
ApiEnum["DirectMessageView"] = "/api/v3/direct-message/view";
|
|
74
41
|
ApiEnum["DirectMessageCreate"] = "/api/v3/direct-message/create";
|
|
@@ -77,92 +44,55 @@ var ApiEnum;
|
|
|
77
44
|
ApiEnum["DirectMessageReactionList"] = "/api/v3/direct-message/reaction-list";
|
|
78
45
|
ApiEnum["DirectMessageAddReaction"] = "/api/v3/direct-message/add-reaction";
|
|
79
46
|
ApiEnum["DirectMessageDeleteReaction"] = "/api/v3/direct-message/delete-reaction";
|
|
80
|
-
/**
|
|
81
|
-
* ******
|
|
82
|
-
* 用户接口
|
|
83
|
-
* ******
|
|
84
|
-
*/
|
|
85
47
|
ApiEnum["UserMe"] = "/api/v3/user/me";
|
|
86
48
|
ApiEnum["UserView"] = "/api/v3/user/view";
|
|
87
49
|
ApiEnum["UserOffline"] = "/api/v3/user/offline";
|
|
88
|
-
/**
|
|
89
|
-
* *******
|
|
90
|
-
* 媒体接口
|
|
91
|
-
* *******
|
|
92
|
-
*/
|
|
93
50
|
ApiEnum["AssetCreate"] = "/api/v3/asset/create";
|
|
94
|
-
/**
|
|
95
|
-
* *******
|
|
96
|
-
* 服务器角色权限相关接口列表
|
|
97
|
-
* *******
|
|
98
|
-
*/
|
|
99
51
|
ApiEnum["GuildRoleList"] = "/api/v3/guild-role/list";
|
|
100
52
|
ApiEnum["GuildRoleCreate"] = "/api/v3/guild-role/create";
|
|
101
53
|
ApiEnum["GuildRoleUpdate"] = "/api/v3/guild-role/update";
|
|
102
54
|
ApiEnum["GuildRoleDelete"] = "/api/v3/guild-role/delete";
|
|
103
55
|
ApiEnum["GuildRoleGrant"] = "/api/v3/guild-role/grant";
|
|
104
56
|
ApiEnum["GuildRoleRevoke"] = "/api/v3/guild-role/revoke";
|
|
105
|
-
/**
|
|
106
|
-
* *******
|
|
107
|
-
* 亲密度相关接口列表
|
|
108
|
-
* *******
|
|
109
|
-
*/
|
|
110
57
|
ApiEnum["IntimacyIndex"] = "/api/v3/intimacy/index";
|
|
111
58
|
ApiEnum["IntimacyUpdate"] = "/api/v3/intimacy/update";
|
|
112
|
-
/**
|
|
113
|
-
* *******
|
|
114
|
-
* 服务器表情相关接口
|
|
115
|
-
* *******
|
|
116
|
-
*/
|
|
117
59
|
ApiEnum["GuildEmojiList"] = "/api/v3/guild-emoji/list";
|
|
118
60
|
ApiEnum["GuildEmojiCreate"] = "/api/v3/guild-emoji/create";
|
|
119
61
|
ApiEnum["GuildEmojiUpdate"] = "/api/v3/guild-emoji/update";
|
|
120
62
|
ApiEnum["GuildEmojiDelete"] = "/api/v3/guild-emoji/delete";
|
|
121
|
-
/**
|
|
122
|
-
* *******
|
|
123
|
-
* 邀请相关接口
|
|
124
|
-
* *******
|
|
125
|
-
*/
|
|
126
63
|
ApiEnum["InviteList"] = "/api/v3/invite/list";
|
|
127
64
|
ApiEnum["InviteCreate"] = "/api/v3/invite/create";
|
|
128
65
|
ApiEnum["InviteDelete"] = "/api/v3/invite/delete";
|
|
129
|
-
/**
|
|
130
|
-
* *******
|
|
131
|
-
* 黑名单相关接口
|
|
132
|
-
* *******
|
|
133
|
-
*/
|
|
134
66
|
ApiEnum["BlacklistList"] = "/api/v3/blacklist/list";
|
|
135
67
|
ApiEnum["BlacklistCreate"] = "/api/v3/blacklist/create";
|
|
136
68
|
ApiEnum["BlacklistDelete"] = "/api/v3/blacklist/delete";
|
|
137
|
-
/**
|
|
138
|
-
* *******
|
|
139
|
-
* Badge 相关文档
|
|
140
|
-
* *******
|
|
141
|
-
*/
|
|
142
69
|
ApiEnum["BadgeGuild"] = "/api/v3/badge/guild";
|
|
143
|
-
/**
|
|
144
|
-
* *******
|
|
145
|
-
* 用户动态相关接口-游戏/进程/音乐
|
|
146
|
-
* *******
|
|
147
|
-
*/
|
|
148
70
|
ApiEnum["GameList"] = "/api/v3/game";
|
|
149
71
|
ApiEnum["GameCreate"] = "/api/v3/game/create";
|
|
150
72
|
ApiEnum["GameUpdate"] = "/api/v3/game/update";
|
|
151
73
|
ApiEnum["GameDelete"] = "/api/v3/game/delete";
|
|
152
74
|
ApiEnum["GameActivity"] = "/api/v3/game/activity";
|
|
153
75
|
ApiEnum["GameDeleteActivity"] = "/api/v3/game/delete-activity";
|
|
154
|
-
/**
|
|
155
|
-
* *******
|
|
156
|
-
* Gateway
|
|
157
|
-
* *******
|
|
158
|
-
*/
|
|
159
76
|
ApiEnum["OAuth2Token"] = "/api/oauth2/token";
|
|
160
|
-
/**
|
|
161
|
-
* *******
|
|
162
|
-
* OAuth2.0相关接口
|
|
163
|
-
* *******
|
|
164
|
-
*/
|
|
165
77
|
ApiEnum["GatewayIndex"] = "/api/v3/gateway/index";
|
|
166
78
|
})(ApiEnum || (ApiEnum = {}));
|
|
79
|
+
const SystemDataEnum = [
|
|
80
|
+
'joined_guild',
|
|
81
|
+
'exited_guild',
|
|
82
|
+
'self_joined_guild',
|
|
83
|
+
'self_exited_guild',
|
|
84
|
+
'joined_channel',
|
|
85
|
+
'exited_channel',
|
|
86
|
+
'updated_channel',
|
|
87
|
+
'added_channel',
|
|
88
|
+
'deleted_channel',
|
|
89
|
+
'pinned_message',
|
|
90
|
+
'deleted_message',
|
|
91
|
+
'guild_member_online',
|
|
92
|
+
'added_reaction',
|
|
93
|
+
'deleted_reaction',
|
|
94
|
+
'updated_message',
|
|
95
|
+
'message_btn_click'
|
|
96
|
+
];
|
|
167
97
|
|
|
168
|
-
export { ApiEnum };
|
|
98
|
+
export { ApiEnum, SystemDataEnum };
|
package/lib/sdk/wss.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { KOOKOptions } from './wss.types.js';
|
|
2
|
+
import { KOOKAPI } from './api.js';
|
|
3
|
+
import { KOOKEventMap } from './message.js';
|
|
4
|
+
export declare class KOOKClient extends KOOKAPI {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(opstion: KOOKOptions);
|
|
7
|
+
on<T extends keyof KOOKEventMap>(key: T, val: (event: KOOKEventMap[T]) => any): this;
|
|
8
|
+
connect(): Promise<void>;
|
|
9
|
+
}
|