woodenfish-bot 2.0.7
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 +3 -0
- package/es/index.js +3189 -0
- package/lib/index.js +3203 -0
- package/package.json +101 -0
- package/typings/index.d.ts +752 -0
|
@@ -0,0 +1,752 @@
|
|
|
1
|
+
import { RestyResponse, RequestOptions } from 'resty-client';
|
|
2
|
+
import WebSocket, { EventEmitter } from 'ws';
|
|
3
|
+
|
|
4
|
+
interface wsResData {
|
|
5
|
+
op: number;
|
|
6
|
+
d?: {
|
|
7
|
+
heartbeat_interval?: number;
|
|
8
|
+
};
|
|
9
|
+
s: number;
|
|
10
|
+
t: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
}
|
|
13
|
+
interface HeartbeatParam {
|
|
14
|
+
op: number;
|
|
15
|
+
d: number;
|
|
16
|
+
}
|
|
17
|
+
interface EventTypes {
|
|
18
|
+
eventType: string;
|
|
19
|
+
eventMsg?: object;
|
|
20
|
+
}
|
|
21
|
+
interface GetWsParam {
|
|
22
|
+
appID: string;
|
|
23
|
+
token: string;
|
|
24
|
+
clientSecret: string;
|
|
25
|
+
sandbox?: boolean;
|
|
26
|
+
shards?: Array<number>;
|
|
27
|
+
intents?: Array<AvailableIntentsEventsEnum>;
|
|
28
|
+
maxRetry?: number;
|
|
29
|
+
}
|
|
30
|
+
interface WsAddressObj {
|
|
31
|
+
url: string;
|
|
32
|
+
shards: number;
|
|
33
|
+
session_start_limit: {
|
|
34
|
+
total: number;
|
|
35
|
+
remaining: number;
|
|
36
|
+
reset_after: number;
|
|
37
|
+
max_concurrency: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
interface WsDataInfo {
|
|
41
|
+
data: WsAddressObj;
|
|
42
|
+
}
|
|
43
|
+
interface SessionRecord {
|
|
44
|
+
sessionID: string;
|
|
45
|
+
seq: number;
|
|
46
|
+
}
|
|
47
|
+
declare enum OpCode {
|
|
48
|
+
DISPATCH = 0,// 服务端进行消息推送
|
|
49
|
+
HEARTBEAT = 1,// 客户端发送心跳
|
|
50
|
+
IDENTIFY = 2,// 鉴权
|
|
51
|
+
RESUME = 6,// 恢复连接
|
|
52
|
+
RECONNECT = 7,// 服务端通知客户端重连
|
|
53
|
+
INVALID_SESSION = 9,// 当identify或resume的时候,如果参数有错,服务端会返回该消息
|
|
54
|
+
HELLO = 10,// 当客户端与网关建立ws连接之后,网关下发的第一条消息
|
|
55
|
+
HEARTBEAT_ACK = 11
|
|
56
|
+
}
|
|
57
|
+
declare enum AvailableIntentsEventsEnum {
|
|
58
|
+
GUILDS = "GUILDS",
|
|
59
|
+
GUILD_MEMBERS = "GUILD_MEMBERS",
|
|
60
|
+
GUILD_MESSAGES = "GUILD_MESSAGES",
|
|
61
|
+
GUILD_MESSAGE_REACTIONS = "GUILD_MESSAGE_REACTIONS",
|
|
62
|
+
DIRECT_MESSAGE = "DIRECT_MESSAGE",
|
|
63
|
+
FORUM_EVENT = "FORUM_EVENT",
|
|
64
|
+
AUDIO_ACTION = "AUDIO_ACTION",
|
|
65
|
+
OPEN_FORUM_EVENT = "OPEN_FORUM_EVENT",
|
|
66
|
+
AUDIO_OR_LIVE_CHANNEL_MEMBER = "AUDIO_OR_LIVE_CHANNEL_MEMBER",
|
|
67
|
+
PUBLIC_GUILD_MESSAGES = "PUBLIC_GUILD_MESSAGES",
|
|
68
|
+
MESSAGE_AUDIT = "MESSAGE_AUDIT",
|
|
69
|
+
INTERACTION = "INTERACTION",
|
|
70
|
+
GROUP_C2C_EVENT = "GROUP_C2C_EVENT"
|
|
71
|
+
}
|
|
72
|
+
declare const WsEventType: {
|
|
73
|
+
[key: string]: AvailableIntentsEventsEnum;
|
|
74
|
+
};
|
|
75
|
+
declare const WSCodes: {
|
|
76
|
+
1000: string;
|
|
77
|
+
4004: string;
|
|
78
|
+
4010: string;
|
|
79
|
+
4011: string;
|
|
80
|
+
4013: string;
|
|
81
|
+
4014: string;
|
|
82
|
+
};
|
|
83
|
+
declare const enum WebsocketCode {
|
|
84
|
+
INVALID_OPCODE = 4001,// 无效的opcode
|
|
85
|
+
INVALID_PAYLOAD = 4002,// 无效的payload
|
|
86
|
+
ERROR_SEQ = 4007,// seq错误
|
|
87
|
+
TOO_FAST_PAYLOAD = 4008,// 发送 payload 过快,请重新连接,并遵守连接后返回的频控信息
|
|
88
|
+
EXPIRED = 4009,// 连接过期,请重连
|
|
89
|
+
INVALID_SHARD = 4010,// 无效的shard
|
|
90
|
+
TOO_MACH_GUILD = 4011,// 连接需要处理的guild过多,请进行合理分片
|
|
91
|
+
INVALID_VERSION = 4012,// 无效的version
|
|
92
|
+
INVALID_INTENTS = 4013,// 无效的intent
|
|
93
|
+
DISALLOWED_INTENTS = 4014,// intent无权限
|
|
94
|
+
ERROR = 4900
|
|
95
|
+
}
|
|
96
|
+
declare const WebsocketCloseReason: ({
|
|
97
|
+
code: number;
|
|
98
|
+
reason: string;
|
|
99
|
+
resume?: undefined;
|
|
100
|
+
} | {
|
|
101
|
+
code: number;
|
|
102
|
+
reason: string;
|
|
103
|
+
resume: boolean;
|
|
104
|
+
})[];
|
|
105
|
+
type IntentEventsMapType = {
|
|
106
|
+
[key in AvailableIntentsEventsEnum]: number;
|
|
107
|
+
};
|
|
108
|
+
declare const IntentEvents: IntentEventsMapType;
|
|
109
|
+
declare const Intents: {
|
|
110
|
+
GUILDS: number;
|
|
111
|
+
GUILD_MEMBERS: number;
|
|
112
|
+
GUILD_BANS: number;
|
|
113
|
+
GUILD_EMOJIS: number;
|
|
114
|
+
GUILD_INTEGRATIONS: number;
|
|
115
|
+
GUILD_WEBHOOKS: number;
|
|
116
|
+
GUILD_INVITES: number;
|
|
117
|
+
GUILD_VOICE_STATES: number;
|
|
118
|
+
GUILD_PRESENCES: number;
|
|
119
|
+
GUILD_MESSAGES: number;
|
|
120
|
+
GUILD_MESSAGE_REACTIONS: number;
|
|
121
|
+
GUILD_MESSAGE_TYPING: number;
|
|
122
|
+
DIRECT_MESSAGES: number;
|
|
123
|
+
DIRECT_MESSAGE_REACTIONS: number;
|
|
124
|
+
DIRECT_MESSAGE_TYPING: number;
|
|
125
|
+
OPEN_FORUM_EVENT: number;
|
|
126
|
+
AUDIO_OR_LIVE_CHANNEL_MEMBER: number;
|
|
127
|
+
GROUP_C2C_EVENT: number;
|
|
128
|
+
INTERACTION: number;
|
|
129
|
+
MESSAGE_AUDIT: number;
|
|
130
|
+
FORUM_EVENT: number;
|
|
131
|
+
AUDIO_ACTION: number;
|
|
132
|
+
PUBLIC_GUILD_MESSAGES: number;
|
|
133
|
+
};
|
|
134
|
+
declare const SessionEvents: {
|
|
135
|
+
CLOSED: string;
|
|
136
|
+
READY: string;
|
|
137
|
+
ERROR: string;
|
|
138
|
+
INVALID_SESSION: string;
|
|
139
|
+
RECONNECT: string;
|
|
140
|
+
DISCONNECT: string;
|
|
141
|
+
EVENT_WS: string;
|
|
142
|
+
RESUMED: string;
|
|
143
|
+
DEAD: string;
|
|
144
|
+
};
|
|
145
|
+
declare const WsObjRequestOptions: (sandbox: boolean) => {
|
|
146
|
+
method: "GET";
|
|
147
|
+
url: string;
|
|
148
|
+
headers: {
|
|
149
|
+
Accept: string;
|
|
150
|
+
'Accept-Encoding': string;
|
|
151
|
+
'Accept-Language': string;
|
|
152
|
+
Connection: string;
|
|
153
|
+
'User-Agent': string;
|
|
154
|
+
Authorization: string;
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
interface AudioAPI {
|
|
159
|
+
postAudio: (channelID: string, value: AudioControl) => Promise<RestyResponse<AudioControl>>;
|
|
160
|
+
botOnMic: (channelID: string) => Promise<RestyResponse<{}>>;
|
|
161
|
+
botOffMic: (channelID: string) => Promise<RestyResponse<{}>>;
|
|
162
|
+
}
|
|
163
|
+
interface AudioControl {
|
|
164
|
+
audioUrl: string;
|
|
165
|
+
text: string;
|
|
166
|
+
status: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* ============= Channel 子频道接口 =============
|
|
171
|
+
*/
|
|
172
|
+
interface ChannelAPI {
|
|
173
|
+
channel: (channelID: string) => Promise<RestyResponse<IChannel>>;
|
|
174
|
+
channels: (guildID: string) => Promise<RestyResponse<IChannel[]>>;
|
|
175
|
+
postChannel: (guildID: string, channel: PostChannelObj) => Promise<RestyResponse<IChannel>>;
|
|
176
|
+
patchChannel: (channelID: string, channel: PatchChannelObj) => Promise<RestyResponse<IChannel>>;
|
|
177
|
+
deleteChannel: (channelID: string) => Promise<RestyResponse<any>>;
|
|
178
|
+
}
|
|
179
|
+
type ChannelType = 0 | 1 | 2 | 3 | 4 | 10005;
|
|
180
|
+
type ChannelSubType = 0 | 1 | 2 | 3;
|
|
181
|
+
interface IChannel extends PostChannelObj {
|
|
182
|
+
id: string;
|
|
183
|
+
guild_id: string;
|
|
184
|
+
owner_id: string;
|
|
185
|
+
speak_permission?: number;
|
|
186
|
+
application_id?: string;
|
|
187
|
+
}
|
|
188
|
+
interface PostChannelObj {
|
|
189
|
+
name: string;
|
|
190
|
+
type: ChannelType;
|
|
191
|
+
sub_type?: ChannelSubType;
|
|
192
|
+
position: number;
|
|
193
|
+
parent_id: string;
|
|
194
|
+
private_type?: number;
|
|
195
|
+
private_user_ids?: string[];
|
|
196
|
+
permissions?: string;
|
|
197
|
+
}
|
|
198
|
+
type PatchChannelObj = Partial<Omit<PostChannelObj, 'sub_type' | 'private_user_ids'>>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* ============= ChannelPermissions 子频道权限接口 =============
|
|
202
|
+
*/
|
|
203
|
+
interface ChannelPermissionsAPI {
|
|
204
|
+
channelPermissions: (channelID: string, userID: string) => Promise<RestyResponse<IChannelPermissions>>;
|
|
205
|
+
putChannelPermissions: (channelID: string, userID: string, p: UpdateChannelPermissions) => Promise<RestyResponse<any>>;
|
|
206
|
+
channelRolePermissions: (channelID: string, roleID: string) => Promise<RestyResponse<IChannelRolePermissions>>;
|
|
207
|
+
putChannelRolePermissions: (channelID: string, roleID: string, p: UpdateChannelPermissions) => Promise<RestyResponse<any>>;
|
|
208
|
+
}
|
|
209
|
+
interface IChannelPermissions {
|
|
210
|
+
channel_id: string;
|
|
211
|
+
user_id: string;
|
|
212
|
+
permissions: string;
|
|
213
|
+
}
|
|
214
|
+
interface IChannelRolePermissions {
|
|
215
|
+
channel_id: string;
|
|
216
|
+
role_id: string;
|
|
217
|
+
permissions: string;
|
|
218
|
+
}
|
|
219
|
+
interface UpdateChannelPermissions {
|
|
220
|
+
add: string;
|
|
221
|
+
remove: string;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* ============= User 用户接口 =============
|
|
226
|
+
*/
|
|
227
|
+
interface MeAPI {
|
|
228
|
+
me: () => Promise<RestyResponse<IUser>>;
|
|
229
|
+
meGuilds: (options?: MeGuildsReq) => Promise<RestyResponse<IGuild[]>>;
|
|
230
|
+
}
|
|
231
|
+
interface IUser {
|
|
232
|
+
id: string;
|
|
233
|
+
username: string;
|
|
234
|
+
avatar: string;
|
|
235
|
+
bot: boolean;
|
|
236
|
+
union_openid: string;
|
|
237
|
+
union_user_account: string;
|
|
238
|
+
}
|
|
239
|
+
interface MeGuildsReq {
|
|
240
|
+
before?: string;
|
|
241
|
+
after?: string;
|
|
242
|
+
limit?: number;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* ============= Guild 频道接口 =============
|
|
247
|
+
*/
|
|
248
|
+
interface GuildAPI {
|
|
249
|
+
guild: (guildID: string) => Promise<RestyResponse<IGuild>>;
|
|
250
|
+
guildMember: (guildID: string, userID: string) => Promise<RestyResponse<IMember>>;
|
|
251
|
+
guildMembers: (guildID: string, pager?: GuildMembersPager) => Promise<RestyResponse<IMember[]>>;
|
|
252
|
+
deleteGuildMember: (guildID: string, userID: string, add_blacklist?: boolean, delete_history_msg_days?: number) => Promise<RestyResponse<any>>;
|
|
253
|
+
guildVoiceMembers: (channelID: string) => Promise<RestyResponse<IVoiceMember[]>>;
|
|
254
|
+
}
|
|
255
|
+
interface IGuild {
|
|
256
|
+
id: string;
|
|
257
|
+
name: string;
|
|
258
|
+
icon: string;
|
|
259
|
+
owner_id: string;
|
|
260
|
+
owner: boolean;
|
|
261
|
+
member_count: number;
|
|
262
|
+
max_members: number;
|
|
263
|
+
description: string;
|
|
264
|
+
joined_at: number;
|
|
265
|
+
channels: IChannel[];
|
|
266
|
+
unionworld_id: string;
|
|
267
|
+
union_org_id: string;
|
|
268
|
+
}
|
|
269
|
+
interface IMember {
|
|
270
|
+
guild_id: string;
|
|
271
|
+
joined_at: string;
|
|
272
|
+
nick: string;
|
|
273
|
+
user: IUser;
|
|
274
|
+
roles: string[];
|
|
275
|
+
deaf: boolean;
|
|
276
|
+
mute: boolean;
|
|
277
|
+
}
|
|
278
|
+
interface IVoiceMember {
|
|
279
|
+
user: IUser;
|
|
280
|
+
nick: string;
|
|
281
|
+
joined_at: string;
|
|
282
|
+
mute: boolean;
|
|
283
|
+
}
|
|
284
|
+
interface GuildMembersPager {
|
|
285
|
+
after: string;
|
|
286
|
+
limit: number;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* ============= Message 消息接口 =============
|
|
291
|
+
*/
|
|
292
|
+
interface MessageAPI {
|
|
293
|
+
message: (channelID: string, messageID: string) => Promise<RestyResponse<IMessageRes>>;
|
|
294
|
+
messages: (channelID: string, pager: MessagesPager) => Promise<RestyResponse<IMessage[]>>;
|
|
295
|
+
postMessage: (channelID: string, message: MessageToCreate) => Promise<RestyResponse<IMessage>>;
|
|
296
|
+
postGroupMessage: (groupID: string, message: MessageToCreate) => Promise<RestyResponse<IMessage>>;
|
|
297
|
+
postC2CMessage: (userID: string, message: MessageToCreate) => Promise<RestyResponse<IMessage>>;
|
|
298
|
+
patchMessage: (channelID: string, messageID: string, message: MessageToCreate) => Promise<RestyResponse<IMessage>>;
|
|
299
|
+
deleteMessage: (channelID: string, messageID: string, hideTip?: boolean) => Promise<RestyResponse<any>>;
|
|
300
|
+
deleteGroupMessage: (groupID: string, messageID: string, hideTip?: boolean) => Promise<RestyResponse<any>>;
|
|
301
|
+
deleteC2CMessage: (userID: string, messageID: string, hideTip?: boolean) => Promise<RestyResponse<any>>;
|
|
302
|
+
postGroupMedia: (groupID: string, message: MediaToCreate) => Promise<RestyResponse<IMedia>>;
|
|
303
|
+
postC2CMedia: (userID: string, message: MediaToCreate) => Promise<RestyResponse<IMedia>>;
|
|
304
|
+
}
|
|
305
|
+
interface MessageAttachment {
|
|
306
|
+
url: string;
|
|
307
|
+
}
|
|
308
|
+
interface EmbedThumbnail {
|
|
309
|
+
url: string;
|
|
310
|
+
}
|
|
311
|
+
interface EmbedField {
|
|
312
|
+
name: string;
|
|
313
|
+
}
|
|
314
|
+
interface Embed {
|
|
315
|
+
title: string;
|
|
316
|
+
description?: string;
|
|
317
|
+
prompt?: string;
|
|
318
|
+
thumbnail?: EmbedThumbnail;
|
|
319
|
+
fields?: EmbedField[];
|
|
320
|
+
}
|
|
321
|
+
interface Ark {
|
|
322
|
+
template_id: string;
|
|
323
|
+
kv: ArkKV[];
|
|
324
|
+
}
|
|
325
|
+
interface ArkKV {
|
|
326
|
+
key: string;
|
|
327
|
+
value: string;
|
|
328
|
+
obj: ArkObj[];
|
|
329
|
+
}
|
|
330
|
+
interface ArkObj {
|
|
331
|
+
obj_kv: ArkObjKV[];
|
|
332
|
+
}
|
|
333
|
+
interface ArkObjKV {
|
|
334
|
+
key: string;
|
|
335
|
+
value: string;
|
|
336
|
+
}
|
|
337
|
+
interface InputNotify {
|
|
338
|
+
input_type: number;
|
|
339
|
+
input_second: number;
|
|
340
|
+
}
|
|
341
|
+
interface IMessage {
|
|
342
|
+
id: string;
|
|
343
|
+
channel_id: string;
|
|
344
|
+
guild_id: string;
|
|
345
|
+
group_id: string;
|
|
346
|
+
content: string;
|
|
347
|
+
timestamp: string;
|
|
348
|
+
edited_timestamp: string;
|
|
349
|
+
mention_everyone: boolean;
|
|
350
|
+
author: IUser;
|
|
351
|
+
member: IMember;
|
|
352
|
+
attachments: MessageAttachment[];
|
|
353
|
+
embeds: Embed[];
|
|
354
|
+
mentions: IUser[];
|
|
355
|
+
ark: Ark;
|
|
356
|
+
seq?: number;
|
|
357
|
+
seq_in_channel?: string;
|
|
358
|
+
}
|
|
359
|
+
interface IMessageRes {
|
|
360
|
+
message: IMessage;
|
|
361
|
+
}
|
|
362
|
+
interface MessagesPager {
|
|
363
|
+
type: 'around' | 'before' | 'after';
|
|
364
|
+
id: string;
|
|
365
|
+
limit: string;
|
|
366
|
+
}
|
|
367
|
+
interface MessageReference {
|
|
368
|
+
message_id: string;
|
|
369
|
+
ignore_get_message_error?: boolean;
|
|
370
|
+
}
|
|
371
|
+
interface MessageToCreate {
|
|
372
|
+
content?: string;
|
|
373
|
+
embed?: Embed;
|
|
374
|
+
ark?: Ark;
|
|
375
|
+
message_reference?: MessageReference;
|
|
376
|
+
image?: string;
|
|
377
|
+
media?: Media;
|
|
378
|
+
msg_id?: string;
|
|
379
|
+
msg_seq?: number;
|
|
380
|
+
input_notify?: InputNotify;
|
|
381
|
+
keyboard?: MessageKeyboard;
|
|
382
|
+
msg_type?: number;
|
|
383
|
+
timestamp?: number;
|
|
384
|
+
}
|
|
385
|
+
interface MediaToCreate {
|
|
386
|
+
file_type: number;
|
|
387
|
+
url: string;
|
|
388
|
+
srv_send_msg: boolean;
|
|
389
|
+
}
|
|
390
|
+
interface IMedia {
|
|
391
|
+
file_uuid: string;
|
|
392
|
+
file_info: string;
|
|
393
|
+
ttl: number;
|
|
394
|
+
}
|
|
395
|
+
interface Media {
|
|
396
|
+
file_info: string;
|
|
397
|
+
}
|
|
398
|
+
interface MessageKeyboard {
|
|
399
|
+
id?: string;
|
|
400
|
+
content?: CustomKeyboard;
|
|
401
|
+
}
|
|
402
|
+
interface CustomKeyboard {
|
|
403
|
+
rows?: Row[];
|
|
404
|
+
}
|
|
405
|
+
interface Row {
|
|
406
|
+
buttons?: Button[];
|
|
407
|
+
}
|
|
408
|
+
interface Button {
|
|
409
|
+
id?: string;
|
|
410
|
+
render_data?: RenderData;
|
|
411
|
+
action?: Action;
|
|
412
|
+
}
|
|
413
|
+
interface RenderData {
|
|
414
|
+
label?: string;
|
|
415
|
+
visited_label?: string;
|
|
416
|
+
style?: number;
|
|
417
|
+
}
|
|
418
|
+
interface Action {
|
|
419
|
+
type?: number;
|
|
420
|
+
permission?: Permission;
|
|
421
|
+
click_limit?: number;
|
|
422
|
+
data?: string;
|
|
423
|
+
at_bot_show_channel_list?: boolean;
|
|
424
|
+
}
|
|
425
|
+
interface Permission {
|
|
426
|
+
type?: number;
|
|
427
|
+
specify_role_ids?: string[];
|
|
428
|
+
specify_user_ids?: string[];
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* ============= DirectMessage 私信接口 =============
|
|
433
|
+
*/
|
|
434
|
+
interface DirectMessageAPI {
|
|
435
|
+
createDirectMessage: (dm: DirectMessageToCreate) => Promise<RestyResponse<IDirectMessage>>;
|
|
436
|
+
postDirectMessage: (guildID: string, msg: MessageToCreate) => Promise<RestyResponse<IMessage>>;
|
|
437
|
+
}
|
|
438
|
+
interface DirectMessageToCreate {
|
|
439
|
+
source_guild_id: string;
|
|
440
|
+
recipient_id: string;
|
|
441
|
+
}
|
|
442
|
+
interface IDirectMessage {
|
|
443
|
+
guild_id: string;
|
|
444
|
+
channel_id: string;
|
|
445
|
+
create_time: string;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* ============= Member 成员接口 =============
|
|
450
|
+
*/
|
|
451
|
+
interface MemberAPI {
|
|
452
|
+
memberAddRole: (guildID: string, roleID: string, userID: string,
|
|
453
|
+
/** 兼容原来传递 channel 对象的逻辑,后续仅支持 string */
|
|
454
|
+
channel?: string | MemberAddRoleBody) => Promise<RestyResponse<any>>;
|
|
455
|
+
memberDeleteRole: (guildID: string, roleID: string, userID: string,
|
|
456
|
+
/** 兼容原来传递 channel 对象的逻辑,后续仅支持 string */
|
|
457
|
+
channel?: string | MemberAddRoleBody) => Promise<RestyResponse<any>>;
|
|
458
|
+
guildRolesMembers: (guildID: string, roleID: string, pager?: any) => Promise<RestyResponse<any>>;
|
|
459
|
+
}
|
|
460
|
+
type MemberAddRoleBody = Pick<IChannel, 'id'>;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* ============= Role 身份组接口 =============
|
|
464
|
+
*/
|
|
465
|
+
interface RoleAPI {
|
|
466
|
+
roles: (guildID: string) => Promise<RestyResponse<GuildRoles>>;
|
|
467
|
+
postRole: (guildID: string, role: Omit<IRole, 'id'>, filter?: IRoleFilter) => Promise<RestyResponse<UpdateRoleRes>>;
|
|
468
|
+
patchRole: (guildID: string, roleID: string, role: IRole, filter?: IRoleFilter) => Promise<RestyResponse<UpdateRoleRes>>;
|
|
469
|
+
deleteRole: (guildID: string, roleID: string) => Promise<RestyResponse<any>>;
|
|
470
|
+
}
|
|
471
|
+
interface IRole {
|
|
472
|
+
id: string;
|
|
473
|
+
name: string;
|
|
474
|
+
color: number;
|
|
475
|
+
hoist: number;
|
|
476
|
+
number: number;
|
|
477
|
+
member_limit: number;
|
|
478
|
+
}
|
|
479
|
+
interface IRoleFilter {
|
|
480
|
+
name?: number;
|
|
481
|
+
color?: number;
|
|
482
|
+
hoist?: number;
|
|
483
|
+
}
|
|
484
|
+
interface GuildRoles {
|
|
485
|
+
guild_id: string;
|
|
486
|
+
roles: IRole[];
|
|
487
|
+
role_num_limit: string;
|
|
488
|
+
}
|
|
489
|
+
interface UpdateRoleRes {
|
|
490
|
+
role_id: string;
|
|
491
|
+
guild_id: string;
|
|
492
|
+
role: IRole;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* ============= Mute 禁言接口 =============
|
|
497
|
+
*/
|
|
498
|
+
interface MuteAPI {
|
|
499
|
+
muteMember: (guildID: string, userID: string, options: MuteOptions) => Promise<RestyResponse<any>>;
|
|
500
|
+
muteAll: (guildID: string, options: MuteOptions) => Promise<RestyResponse<any>>;
|
|
501
|
+
muteMembers: (guildID: string, userIDList: Array<string>, options: MuteOptions) => Promise<RestyResponse<any>>;
|
|
502
|
+
}
|
|
503
|
+
interface MuteOptions {
|
|
504
|
+
timeTo?: string;
|
|
505
|
+
seconds?: string;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* ============= Announce 公告接口 =============
|
|
510
|
+
*/
|
|
511
|
+
interface AnnounceAPI {
|
|
512
|
+
postGuildAnnounce: (guildID: string, channelID: string, messageID: string) => Promise<RestyResponse<IAnnounce>>;
|
|
513
|
+
deleteGuildAnnounce: (guildID: string, messageID: string) => Promise<RestyResponse<any>>;
|
|
514
|
+
postGuildRecommend: (guildID: string, recommendObj: RecommendObj) => Promise<RestyResponse<IAnnounce>>;
|
|
515
|
+
postChannelAnnounce: (channelID: string, messageID: string) => Promise<RestyResponse<IAnnounce>>;
|
|
516
|
+
deleteChannelAnnounce: (channelID: string, messageID: string) => Promise<RestyResponse<any>>;
|
|
517
|
+
}
|
|
518
|
+
interface IAnnounce {
|
|
519
|
+
guild_id: string;
|
|
520
|
+
channel_id: string;
|
|
521
|
+
message_id: string;
|
|
522
|
+
announce_type?: number;
|
|
523
|
+
recommend_channels?: RecommendChannel[];
|
|
524
|
+
}
|
|
525
|
+
interface RecommendObj {
|
|
526
|
+
announces_type?: number;
|
|
527
|
+
recommend_channels: RecommendChannel[];
|
|
528
|
+
}
|
|
529
|
+
interface RecommendChannel {
|
|
530
|
+
channel_id: string;
|
|
531
|
+
introduce: string;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* ============= Schedule 日程接口 =============
|
|
536
|
+
*/
|
|
537
|
+
interface ScheduleAPI {
|
|
538
|
+
schedule: (channelID: string, scheduleID: string) => Promise<RestyResponse<ISchedule>>;
|
|
539
|
+
schedules: (channelID: string, since?: string) => Promise<RestyResponse<ISchedule[]>>;
|
|
540
|
+
postSchedule: (channelID: string, schedule: ScheduleToCreate) => Promise<RestyResponse<ISchedule>>;
|
|
541
|
+
patchSchedule: (channelID: string, scheduleID: string, schedule: ScheduleToPatch) => Promise<RestyResponse<ISchedule>>;
|
|
542
|
+
deleteSchedule: (channelID: string, scheduleID: string) => Promise<RestyResponse<any>>;
|
|
543
|
+
}
|
|
544
|
+
type ScheduleRemindType = '0' | '1' | '2' | '3' | '4' | '5';
|
|
545
|
+
interface ScheduleToCreate {
|
|
546
|
+
name: string;
|
|
547
|
+
description?: string;
|
|
548
|
+
creator?: IMember;
|
|
549
|
+
start_timestamp: string;
|
|
550
|
+
end_timestamp: string;
|
|
551
|
+
jump_channel_id?: string;
|
|
552
|
+
remind_type: ScheduleRemindType;
|
|
553
|
+
}
|
|
554
|
+
interface ISchedule extends ScheduleToCreate {
|
|
555
|
+
id: string;
|
|
556
|
+
}
|
|
557
|
+
type ScheduleToPatch = Partial<Omit<ISchedule, 'id'>>;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* ============= Reaction 接口 =============
|
|
561
|
+
*/
|
|
562
|
+
interface ReactionAPI {
|
|
563
|
+
postReaction: (channelID: string, reactionToCreate: ReactionObj) => Promise<RestyResponse<any>>;
|
|
564
|
+
deleteReaction: (channelID: string, reactionToDelete: ReactionObj) => Promise<RestyResponse<any>>;
|
|
565
|
+
getReactionUserList: (channelID: string, reactionToDelete: ReactionObj, options: ReactionUserListObj) => Promise<RestyResponse<any>>;
|
|
566
|
+
}
|
|
567
|
+
interface ReactionObj {
|
|
568
|
+
message_id: string;
|
|
569
|
+
emoji_type: number;
|
|
570
|
+
emoji_id: string;
|
|
571
|
+
}
|
|
572
|
+
interface ReactionUserListObj {
|
|
573
|
+
cookie: string;
|
|
574
|
+
limit: number;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* ============= Interaction 接口 =============
|
|
579
|
+
*/
|
|
580
|
+
interface InteractionAPI {
|
|
581
|
+
putInteraction: (interactionID: string, interactionData: InteractionData) => Promise<RestyResponse<any>>;
|
|
582
|
+
}
|
|
583
|
+
interface InteractionData {
|
|
584
|
+
code: number;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* ============= PinsMessage 接口 =============
|
|
589
|
+
*/
|
|
590
|
+
interface PinsMessageAPI {
|
|
591
|
+
pinsMessage: (channelID: string) => Promise<RestyResponse<IPinsMessage>>;
|
|
592
|
+
putPinsMessage: (channelID: string, messageID: string) => Promise<RestyResponse<IPinsMessage>>;
|
|
593
|
+
deletePinsMessage: (channelID: string, messageID: string) => Promise<RestyResponse<any>>;
|
|
594
|
+
}
|
|
595
|
+
interface IPinsMessage {
|
|
596
|
+
guild_id: string;
|
|
597
|
+
channel_id: string;
|
|
598
|
+
message_ids: string[];
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* ============= GuildPermission API权限接口 =============
|
|
603
|
+
*/
|
|
604
|
+
interface GuildPermissionsAPI {
|
|
605
|
+
permissions: (guildID: string) => Promise<RestyResponse<GuildPermissionRes>>;
|
|
606
|
+
postPermissionDemand: (guildID: string, permissionDemandObj: PermissionDemandToCreate) => Promise<RestyResponse<GuildPermissionDemand>>;
|
|
607
|
+
}
|
|
608
|
+
interface GuildPermission {
|
|
609
|
+
path: string;
|
|
610
|
+
method: string;
|
|
611
|
+
desc: string;
|
|
612
|
+
auth_status: number;
|
|
613
|
+
}
|
|
614
|
+
interface GuildPermissionRes {
|
|
615
|
+
apis: GuildPermission[];
|
|
616
|
+
}
|
|
617
|
+
interface GuildPermissionDemand {
|
|
618
|
+
guild_id: string;
|
|
619
|
+
channel_id: string;
|
|
620
|
+
api_identify: GuildPermissionDemandIdentify;
|
|
621
|
+
title: string;
|
|
622
|
+
desc: string;
|
|
623
|
+
}
|
|
624
|
+
interface PermissionDemandToCreate {
|
|
625
|
+
channel_id: string;
|
|
626
|
+
api_identify: GuildPermissionDemandIdentify;
|
|
627
|
+
desc?: string;
|
|
628
|
+
}
|
|
629
|
+
interface GuildPermissionDemandIdentify {
|
|
630
|
+
path: string;
|
|
631
|
+
method: string;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
type OpenAPIRequest = <T extends Record<any, any> = any>(options: RequestOptions) => Promise<RestyResponse<T>>;
|
|
635
|
+
interface Config {
|
|
636
|
+
appID: string;
|
|
637
|
+
token: string;
|
|
638
|
+
clientSecret?: string;
|
|
639
|
+
access_token?: string;
|
|
640
|
+
sandbox?: boolean;
|
|
641
|
+
}
|
|
642
|
+
interface IOpenAPI {
|
|
643
|
+
config: Config;
|
|
644
|
+
request: OpenAPIRequest;
|
|
645
|
+
guildApi: GuildAPI;
|
|
646
|
+
channelApi: ChannelAPI;
|
|
647
|
+
meApi: MeAPI;
|
|
648
|
+
messageApi: MessageAPI;
|
|
649
|
+
memberApi: MemberAPI;
|
|
650
|
+
roleApi: RoleAPI;
|
|
651
|
+
muteApi: MuteAPI;
|
|
652
|
+
announceApi: AnnounceAPI;
|
|
653
|
+
scheduleApi: ScheduleAPI;
|
|
654
|
+
directMessageApi: DirectMessageAPI;
|
|
655
|
+
channelPermissionsApi: ChannelPermissionsAPI;
|
|
656
|
+
audioApi: AudioAPI;
|
|
657
|
+
guildPermissionsApi: GuildPermissionsAPI;
|
|
658
|
+
reactionApi: ReactionAPI;
|
|
659
|
+
interactionApi: InteractionAPI;
|
|
660
|
+
pinsMessageApi: PinsMessageAPI;
|
|
661
|
+
}
|
|
662
|
+
type APIVersion = `v${number}`;
|
|
663
|
+
interface Token {
|
|
664
|
+
appID: number;
|
|
665
|
+
accessToken: string;
|
|
666
|
+
type: string;
|
|
667
|
+
}
|
|
668
|
+
interface WebsocketAPI {
|
|
669
|
+
ws: () => any;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
type Nullish = null | undefined;
|
|
673
|
+
|
|
674
|
+
declare class OpenAPI implements IOpenAPI {
|
|
675
|
+
static newClient(config: Config): OpenAPI;
|
|
676
|
+
config: Config;
|
|
677
|
+
guildApi: GuildAPI;
|
|
678
|
+
channelApi: ChannelAPI;
|
|
679
|
+
meApi: MeAPI;
|
|
680
|
+
messageApi: MessageAPI;
|
|
681
|
+
memberApi: MemberAPI;
|
|
682
|
+
roleApi: RoleAPI;
|
|
683
|
+
muteApi: MuteAPI;
|
|
684
|
+
announceApi: AnnounceAPI;
|
|
685
|
+
scheduleApi: ScheduleAPI;
|
|
686
|
+
directMessageApi: DirectMessageAPI;
|
|
687
|
+
channelPermissionsApi: ChannelPermissionsAPI;
|
|
688
|
+
audioApi: AudioAPI;
|
|
689
|
+
reactionApi: ReactionAPI;
|
|
690
|
+
interactionApi: InteractionAPI;
|
|
691
|
+
pinsMessageApi: PinsMessageAPI;
|
|
692
|
+
guildPermissionsApi: GuildPermissionsAPI;
|
|
693
|
+
constructor(config: Config);
|
|
694
|
+
register(client: IOpenAPI): void;
|
|
695
|
+
request<T extends Record<any, any> = any>(options: any): Promise<RestyResponse<T>>;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
declare class Ws {
|
|
699
|
+
ws: WebSocket;
|
|
700
|
+
event: EventEmitter;
|
|
701
|
+
config: GetWsParam;
|
|
702
|
+
heartbeatInterval: number;
|
|
703
|
+
heartbeatParam: {
|
|
704
|
+
op: OpCode;
|
|
705
|
+
d: null;
|
|
706
|
+
};
|
|
707
|
+
isReconnect: boolean;
|
|
708
|
+
sessionRecord: {
|
|
709
|
+
sessionID: string;
|
|
710
|
+
seq: number;
|
|
711
|
+
};
|
|
712
|
+
alive: boolean;
|
|
713
|
+
constructor(config: GetWsParam, event: EventEmitter, sessionRecord?: SessionRecord);
|
|
714
|
+
createWebsocket(wsData: WsAddressObj): WebSocket;
|
|
715
|
+
createListening(): WebSocket;
|
|
716
|
+
connectWs(wsData: WsAddressObj): void;
|
|
717
|
+
authWs(): void;
|
|
718
|
+
getValidIntents(): number | undefined;
|
|
719
|
+
getValidIntentsType(): AvailableIntentsEventsEnum[];
|
|
720
|
+
checkShards(shardsArr: Array<number> | undefined): void | number[];
|
|
721
|
+
sendWs(msg: unknown): void;
|
|
722
|
+
reconnect(): void;
|
|
723
|
+
reconnectWs(): void;
|
|
724
|
+
dispatchEvent(eventType: string, wsRes: wsResData): void;
|
|
725
|
+
closeWs(): void;
|
|
726
|
+
handleWsCloseEvent(code: number): void;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
declare class Session {
|
|
730
|
+
config: GetWsParam;
|
|
731
|
+
heartbeatInterval: number;
|
|
732
|
+
ws: Ws;
|
|
733
|
+
event: EventEmitter;
|
|
734
|
+
sessionRecord: SessionRecord | undefined;
|
|
735
|
+
constructor(config: GetWsParam, event: EventEmitter, sessionRecord?: SessionRecord);
|
|
736
|
+
createSession(): void;
|
|
737
|
+
closeSession(): void;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
declare class WebsocketClient extends EventEmitter {
|
|
741
|
+
session: Session;
|
|
742
|
+
retry: number;
|
|
743
|
+
constructor(config: GetWsParam);
|
|
744
|
+
connect(config: GetWsParam, sessionRecord?: SessionRecord): Session;
|
|
745
|
+
disconnect(): void;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
declare function selectOpenAPIVersion(version: APIVersion): false | undefined;
|
|
749
|
+
declare function createOpenAPI(config: Config): OpenAPI;
|
|
750
|
+
declare function createWebsocket(config: GetWsParam): WebsocketClient;
|
|
751
|
+
|
|
752
|
+
export { type APIVersion, type Action, type AnnounceAPI, type Ark, type ArkKV, type ArkObj, type ArkObjKV, type AudioAPI, type AudioControl, AvailableIntentsEventsEnum, type Button, type ChannelAPI, type ChannelPermissionsAPI, type ChannelSubType, type ChannelType, type Config, type CustomKeyboard, type DirectMessageAPI, type DirectMessageToCreate, type Embed, type EmbedField, type EmbedThumbnail, type EventTypes, type GetWsParam, type GuildAPI, type GuildMembersPager, type GuildPermission, type GuildPermissionDemand, type GuildPermissionDemandIdentify, type GuildPermissionRes, type GuildPermissionsAPI, type GuildRoles, type HeartbeatParam, type IAnnounce, type IChannel, type IChannelPermissions, type IChannelRolePermissions, type IDirectMessage, type IGuild, type IMedia, type IMember, type IMessage, type IMessageRes, type IOpenAPI, type IPinsMessage, type IRole, type IRoleFilter, type ISchedule, type IUser, type IVoiceMember, type InputNotify, IntentEvents, type IntentEventsMapType, Intents, type InteractionAPI, type InteractionData, type MeAPI, type MeGuildsReq, type Media, type MediaToCreate, type MemberAPI, type MemberAddRoleBody, type MessageAPI, type MessageAttachment, type MessageKeyboard, type MessageReference, type MessageToCreate, type MessagesPager, type MuteAPI, type MuteOptions, type Nullish, OpCode, type OpenAPIRequest, type PatchChannelObj, type Permission, type PermissionDemandToCreate, type PinsMessageAPI, type PostChannelObj, type ReactionAPI, type ReactionObj, type ReactionUserListObj, type RecommendChannel, type RecommendObj, type RenderData, type RoleAPI, type Row, type ScheduleAPI, type ScheduleRemindType, type ScheduleToCreate, type ScheduleToPatch, SessionEvents, type SessionRecord, type Token, type UpdateChannelPermissions, type UpdateRoleRes, WSCodes, type WebsocketAPI, WebsocketCloseReason, WebsocketCode, type WsAddressObj, type WsDataInfo, WsEventType, WsObjRequestOptions, createOpenAPI, createWebsocket, selectOpenAPIVersion, type wsResData };
|