alemonjs 2.1.44 → 2.1.45
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/bin/updateConfig.js +3 -1
- package/lib/app/hook-use-api.d.ts +226 -4
- package/lib/app/hook-use-api.js +912 -11
- package/lib/app/index.js +1 -1
- package/lib/core/index.js +1 -1
- package/lib/core/utils.d.ts +5 -0
- package/lib/core/utils.js +19 -2
- package/lib/index.js +2 -2
- package/lib/types/actions.d.ts +398 -1
- package/lib/types/client/index.d.ts +73 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/standard.d.ts +51 -0
- package/lib/types/standard.js +1 -0
- package/package.json +4 -3
package/lib/app/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { expendCycle } from './event-processor-cycle.js';
|
|
|
14
14
|
export { expendEvent } from './event-processor-event.js';
|
|
15
15
|
export { expendMiddleware } from './event-processor-middleware.js';
|
|
16
16
|
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './event-processor-subscribe.js';
|
|
17
|
-
export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, useMember, useMention, useMessage, useSend, useSends } from './hook-use-api.js';
|
|
17
|
+
export { createSelects, onSelects, unChildren, useAnnounce, useChannel, useClient, useGuild, useHistory, useMe, useMedia, useMember, useMention, useMessage, usePermission, useReaction, useRequest, useRole, useSend, useSends, useUser } from './hook-use-api.js';
|
|
18
18
|
export { onState, unState, useState } from './hook-use-state.js';
|
|
19
19
|
export { useObserver, useSubscribe } from './hook-use-subscribe.js';
|
|
20
20
|
export { MessageDirect, createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './message-api.js';
|
package/lib/core/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { ResultCode } from './variable.js';
|
|
2
2
|
export { getConfig, getConfigValue, onWatchConfigValue } from './config.js';
|
|
3
|
-
export { createEventName, createHash, createResult, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey } from './utils.js';
|
|
3
|
+
export { createEventName, createHash, createResult, createUserHashKey, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, isMaster, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey } from './utils.js';
|
package/lib/core/utils.d.ts
CHANGED
|
@@ -6,10 +6,15 @@ export declare const createHash: (str: string, options?: {
|
|
|
6
6
|
}) => string;
|
|
7
7
|
export declare const fastHash: (str: string) => string;
|
|
8
8
|
export declare const getCachedRegExp: (pattern: string | RegExp) => RegExp;
|
|
9
|
+
export declare const createUserHashKey: (event: {
|
|
10
|
+
UserId: string;
|
|
11
|
+
Platform: string;
|
|
12
|
+
}) => string;
|
|
9
13
|
export declare const useUserHashKey: (event: {
|
|
10
14
|
UserId: string;
|
|
11
15
|
Platform: string;
|
|
12
16
|
}) => string;
|
|
17
|
+
export declare const isMaster: (UserId: string, platform: string) => any;
|
|
13
18
|
export declare const createEventName: (url: string, appKey: string) => string;
|
|
14
19
|
export declare const stringToNumber: (str: string, size?: number) => number;
|
|
15
20
|
export declare const getRecursiveDirFiles: (dir: string, condition?: (func: Dirent) => boolean) => {
|
package/lib/core/utils.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs__default, { existsSync, readdirSync } from 'fs';
|
|
|
3
3
|
import path__default, { join } from 'path';
|
|
4
4
|
import { fileSuffixResponse, ResultCode } from './variable.js';
|
|
5
5
|
import module from 'module';
|
|
6
|
+
import { getConfigValue } from './config.js';
|
|
6
7
|
|
|
7
8
|
const initRequire = () => { };
|
|
8
9
|
initRequire.resolve = () => '';
|
|
@@ -32,9 +33,25 @@ const getCachedRegExp = (pattern) => {
|
|
|
32
33
|
}
|
|
33
34
|
return cached;
|
|
34
35
|
};
|
|
35
|
-
const
|
|
36
|
+
const createUserHashKey = (event) => {
|
|
36
37
|
return fastHash(`${event.Platform}:${event.UserId}`);
|
|
37
38
|
};
|
|
39
|
+
const useUserHashKey = createUserHashKey;
|
|
40
|
+
const isMaster = (UserId, platform) => {
|
|
41
|
+
const values = getConfigValue() || {};
|
|
42
|
+
const mainMasterKey = values.master_key || [];
|
|
43
|
+
const mainMasterId = values.master_id || [];
|
|
44
|
+
const value = values[platform] || {};
|
|
45
|
+
const masterKey = value.master_key || [];
|
|
46
|
+
const masterId = value.master_id || [];
|
|
47
|
+
const UserKey = createUserHashKey({
|
|
48
|
+
Platform: platform,
|
|
49
|
+
UserId: UserId
|
|
50
|
+
});
|
|
51
|
+
const cMaster = mainMasterKey.concat(masterKey);
|
|
52
|
+
const cMasterId = mainMasterId.concat(masterId);
|
|
53
|
+
return cMaster.includes(UserKey) || cMasterId.includes(UserId);
|
|
54
|
+
};
|
|
38
55
|
const createEventName = (url, appKey) => {
|
|
39
56
|
let uri = url;
|
|
40
57
|
if (process.platform === 'win32') {
|
|
@@ -135,4 +152,4 @@ const createResult = (code, message, data) => {
|
|
|
135
152
|
};
|
|
136
153
|
};
|
|
137
154
|
|
|
138
|
-
export { createEventName, createHash, createResult, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey };
|
|
155
|
+
export { createEventName, createHash, createResult, createUserHashKey, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, isMaster, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey };
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ActionsEventEnum } from './types/event/actions.js';
|
|
2
2
|
export { ResultCode } from './core/variable.js';
|
|
3
3
|
export { getConfig, getConfigValue, onWatchConfigValue } from './core/config.js';
|
|
4
|
-
export { createEventName, createHash, createResult, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
4
|
+
export { createEventName, createHash, createResult, createUserHashKey, fastHash, getCachedRegExp, getInputExportPath, getRecursiveDirFiles, isMaster, sanitizeForSerialization, showErrorModule, stringToNumber, useUserHashKey } from './core/utils.js';
|
|
5
5
|
export { cbpClient } from './cbp/connects/client.js';
|
|
6
6
|
export { cbpPlatform } from './cbp/connects/platform.js';
|
|
7
7
|
export { cbpServer } from './cbp/server/main.js';
|
|
@@ -21,7 +21,7 @@ export { expendCycle } from './app/event-processor-cycle.js';
|
|
|
21
21
|
export { expendEvent } from './app/event-processor-event.js';
|
|
22
22
|
export { expendMiddleware } from './app/event-processor-middleware.js';
|
|
23
23
|
export { expendSubscribe, expendSubscribeCreate, expendSubscribeMount, expendSubscribeUnmount } from './app/event-processor-subscribe.js';
|
|
24
|
-
export { createSelects, onSelects, unChildren, useChannel, useClient, useMe, useMember, useMention, useMessage, useSend, useSends } from './app/hook-use-api.js';
|
|
24
|
+
export { createSelects, onSelects, unChildren, useAnnounce, useChannel, useClient, useGuild, useHistory, useMe, useMedia, useMember, useMention, useMessage, usePermission, useReaction, useRequest, useRole, useSend, useSends, useUser } from './app/hook-use-api.js';
|
|
25
25
|
export { onState, unState, useState } from './app/hook-use-state.js';
|
|
26
26
|
export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
|
|
27
27
|
export { MessageDirect, createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './app/message-api.js';
|
package/lib/types/actions.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataEnums } from './message';
|
|
2
|
+
import { PaginationParams } from './standard';
|
|
2
3
|
export type ActionMessageSend = {
|
|
3
4
|
action: 'message.send';
|
|
4
5
|
payload: {
|
|
@@ -36,6 +37,49 @@ export type ActionMessageDelete = {
|
|
|
36
37
|
action: 'message.delete';
|
|
37
38
|
payload: {
|
|
38
39
|
MessageId: string;
|
|
40
|
+
ChannelId?: string;
|
|
41
|
+
event?: any;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type ActionMessageEdit = {
|
|
45
|
+
action: 'message.edit';
|
|
46
|
+
payload: {
|
|
47
|
+
ChannelId: string;
|
|
48
|
+
MessageId: string;
|
|
49
|
+
params: {
|
|
50
|
+
format?: DataEnums[];
|
|
51
|
+
};
|
|
52
|
+
event?: any;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type ActionMessagePin = {
|
|
56
|
+
action: 'message.pin';
|
|
57
|
+
payload: {
|
|
58
|
+
ChannelId: string;
|
|
59
|
+
MessageId: string;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type ActionMessageUnpin = {
|
|
63
|
+
action: 'message.unpin';
|
|
64
|
+
payload: {
|
|
65
|
+
ChannelId: string;
|
|
66
|
+
MessageId: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type ActionReactionAdd = {
|
|
70
|
+
action: 'reaction.add';
|
|
71
|
+
payload: {
|
|
72
|
+
ChannelId: string;
|
|
73
|
+
MessageId: string;
|
|
74
|
+
EmojiId: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
export type ActionReactionRemove = {
|
|
78
|
+
action: 'reaction.remove';
|
|
79
|
+
payload: {
|
|
80
|
+
ChannelId: string;
|
|
81
|
+
MessageId: string;
|
|
82
|
+
EmojiId: string;
|
|
39
83
|
};
|
|
40
84
|
};
|
|
41
85
|
export type ActionFileSendChannel = {
|
|
@@ -83,15 +127,368 @@ export type ActionMessageForwardChannel = {
|
|
|
83
127
|
}[];
|
|
84
128
|
};
|
|
85
129
|
};
|
|
130
|
+
export type ActionMemberInfo = {
|
|
131
|
+
action: 'member.info';
|
|
132
|
+
payload: {
|
|
133
|
+
event?: any;
|
|
134
|
+
params: {
|
|
135
|
+
userId: string;
|
|
136
|
+
guildId?: string;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
export type ActionMemberList = {
|
|
141
|
+
action: 'member.list';
|
|
142
|
+
payload: {
|
|
143
|
+
GuildId: string;
|
|
144
|
+
params?: PaginationParams;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export type ActionMemberKick = {
|
|
148
|
+
action: 'member.kick';
|
|
149
|
+
payload: {
|
|
150
|
+
GuildId: string;
|
|
151
|
+
UserId: string;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
export type ActionMemberBan = {
|
|
155
|
+
action: 'member.ban';
|
|
156
|
+
payload: {
|
|
157
|
+
GuildId: string;
|
|
158
|
+
UserId: string;
|
|
159
|
+
params?: {
|
|
160
|
+
reason?: string;
|
|
161
|
+
duration?: number;
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export type ActionMemberUnban = {
|
|
166
|
+
action: 'member.unban';
|
|
167
|
+
payload: {
|
|
168
|
+
GuildId: string;
|
|
169
|
+
UserId: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
export type ActionGuildInfo = {
|
|
173
|
+
action: 'guild.info';
|
|
174
|
+
payload: {
|
|
175
|
+
GuildId: string;
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
export type ActionGuildList = {
|
|
179
|
+
action: 'guild.list';
|
|
180
|
+
payload: object;
|
|
181
|
+
};
|
|
182
|
+
export type ActionChannelInfo = {
|
|
183
|
+
action: 'channel.info';
|
|
184
|
+
payload: {
|
|
185
|
+
ChannelId: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
export type ActionChannelList = {
|
|
189
|
+
action: 'channel.list';
|
|
190
|
+
payload: {
|
|
191
|
+
GuildId: string;
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
export type ActionChannelCreate = {
|
|
195
|
+
action: 'channel.create';
|
|
196
|
+
payload: {
|
|
197
|
+
GuildId: string;
|
|
198
|
+
params: {
|
|
199
|
+
name: string;
|
|
200
|
+
type?: string;
|
|
201
|
+
parentId?: string;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
export type ActionChannelUpdate = {
|
|
206
|
+
action: 'channel.update';
|
|
207
|
+
payload: {
|
|
208
|
+
ChannelId: string;
|
|
209
|
+
params: {
|
|
210
|
+
name?: string;
|
|
211
|
+
topic?: string;
|
|
212
|
+
position?: number;
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
};
|
|
216
|
+
export type ActionChannelDelete = {
|
|
217
|
+
action: 'channel.delete';
|
|
218
|
+
payload: {
|
|
219
|
+
ChannelId: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
export type ActionRoleList = {
|
|
223
|
+
action: 'role.list';
|
|
224
|
+
payload: {
|
|
225
|
+
GuildId: string;
|
|
226
|
+
};
|
|
227
|
+
};
|
|
228
|
+
export type ActionRoleCreate = {
|
|
229
|
+
action: 'role.create';
|
|
230
|
+
payload: {
|
|
231
|
+
GuildId: string;
|
|
232
|
+
params: {
|
|
233
|
+
name: string;
|
|
234
|
+
color?: number;
|
|
235
|
+
permissions?: string;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
export type ActionRoleUpdate = {
|
|
240
|
+
action: 'role.update';
|
|
241
|
+
payload: {
|
|
242
|
+
GuildId: string;
|
|
243
|
+
RoleId: string;
|
|
244
|
+
params: {
|
|
245
|
+
name?: string;
|
|
246
|
+
color?: number;
|
|
247
|
+
permissions?: string;
|
|
248
|
+
};
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
export type ActionRoleDelete = {
|
|
252
|
+
action: 'role.delete';
|
|
253
|
+
payload: {
|
|
254
|
+
GuildId: string;
|
|
255
|
+
RoleId: string;
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
export type ActionRoleAssign = {
|
|
259
|
+
action: 'role.assign';
|
|
260
|
+
payload: {
|
|
261
|
+
GuildId: string;
|
|
262
|
+
UserId: string;
|
|
263
|
+
RoleId: string;
|
|
264
|
+
};
|
|
265
|
+
};
|
|
266
|
+
export type ActionRoleRemove = {
|
|
267
|
+
action: 'role.remove';
|
|
268
|
+
payload: {
|
|
269
|
+
GuildId: string;
|
|
270
|
+
UserId: string;
|
|
271
|
+
RoleId: string;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
86
274
|
export type ActionMeInfo = {
|
|
87
275
|
action: 'me.info';
|
|
88
276
|
payload: object;
|
|
89
277
|
};
|
|
278
|
+
export type ActionMeGuilds = {
|
|
279
|
+
action: 'me.guilds';
|
|
280
|
+
payload: object;
|
|
281
|
+
};
|
|
282
|
+
export type ActionMeThreads = {
|
|
283
|
+
action: 'me.threads';
|
|
284
|
+
payload: object;
|
|
285
|
+
};
|
|
286
|
+
export type ActionMeFriends = {
|
|
287
|
+
action: 'me.friends';
|
|
288
|
+
payload: object;
|
|
289
|
+
};
|
|
290
|
+
export type ActionMessageGet = {
|
|
291
|
+
action: 'message.get';
|
|
292
|
+
payload: {
|
|
293
|
+
MessageId: string;
|
|
294
|
+
};
|
|
295
|
+
};
|
|
296
|
+
export type ActionGuildUpdate = {
|
|
297
|
+
action: 'guild.update';
|
|
298
|
+
payload: {
|
|
299
|
+
GuildId: string;
|
|
300
|
+
params: {
|
|
301
|
+
name?: string;
|
|
302
|
+
};
|
|
303
|
+
};
|
|
304
|
+
};
|
|
305
|
+
export type ActionGuildLeave = {
|
|
306
|
+
action: 'guild.leave';
|
|
307
|
+
payload: {
|
|
308
|
+
GuildId: string;
|
|
309
|
+
params?: {
|
|
310
|
+
isDismiss?: boolean;
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
export type ActionGuildMute = {
|
|
315
|
+
action: 'guild.mute';
|
|
316
|
+
payload: {
|
|
317
|
+
GuildId: string;
|
|
318
|
+
params: {
|
|
319
|
+
enable: boolean;
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
export type ActionMemberMute = {
|
|
324
|
+
action: 'member.mute';
|
|
325
|
+
payload: {
|
|
326
|
+
GuildId: string;
|
|
327
|
+
UserId: string;
|
|
328
|
+
params: {
|
|
329
|
+
duration: number;
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
};
|
|
333
|
+
export type ActionMemberAdmin = {
|
|
334
|
+
action: 'member.admin';
|
|
335
|
+
payload: {
|
|
336
|
+
GuildId: string;
|
|
337
|
+
UserId: string;
|
|
338
|
+
params: {
|
|
339
|
+
enable: boolean;
|
|
340
|
+
};
|
|
341
|
+
};
|
|
342
|
+
};
|
|
343
|
+
export type ActionMemberCard = {
|
|
344
|
+
action: 'member.card';
|
|
345
|
+
payload: {
|
|
346
|
+
GuildId: string;
|
|
347
|
+
UserId: string;
|
|
348
|
+
params: {
|
|
349
|
+
card: string;
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
export type ActionMemberTitle = {
|
|
354
|
+
action: 'member.title';
|
|
355
|
+
payload: {
|
|
356
|
+
GuildId: string;
|
|
357
|
+
UserId: string;
|
|
358
|
+
params: {
|
|
359
|
+
title: string;
|
|
360
|
+
duration?: number;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
export type ActionRequestFriend = {
|
|
365
|
+
action: 'request.friend';
|
|
366
|
+
payload: {
|
|
367
|
+
params: {
|
|
368
|
+
flag: string;
|
|
369
|
+
approve: boolean;
|
|
370
|
+
remark?: string;
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
export type ActionRequestGuild = {
|
|
375
|
+
action: 'request.guild';
|
|
376
|
+
payload: {
|
|
377
|
+
params: {
|
|
378
|
+
flag: string;
|
|
379
|
+
subType: string;
|
|
380
|
+
approve: boolean;
|
|
381
|
+
reason?: string;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
export type ActionUserInfo = {
|
|
386
|
+
action: 'user.info';
|
|
387
|
+
payload: {
|
|
388
|
+
UserId: string;
|
|
389
|
+
};
|
|
390
|
+
};
|
|
391
|
+
export type ActionMediaUpload = {
|
|
392
|
+
action: 'media.upload';
|
|
393
|
+
payload: {
|
|
394
|
+
params: {
|
|
395
|
+
type: 'image' | 'audio' | 'video' | 'file';
|
|
396
|
+
url?: string;
|
|
397
|
+
data?: string;
|
|
398
|
+
name?: string;
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
export type ActionMediaSendChannel = {
|
|
403
|
+
action: 'media.send.channel';
|
|
404
|
+
payload: {
|
|
405
|
+
ChannelId: string;
|
|
406
|
+
params: {
|
|
407
|
+
type: 'image' | 'audio' | 'video' | 'file';
|
|
408
|
+
url?: string;
|
|
409
|
+
data?: string;
|
|
410
|
+
name?: string;
|
|
411
|
+
};
|
|
412
|
+
};
|
|
413
|
+
};
|
|
414
|
+
export type ActionMediaSendUser = {
|
|
415
|
+
action: 'media.send.user';
|
|
416
|
+
payload: {
|
|
417
|
+
UserId: string;
|
|
418
|
+
params: {
|
|
419
|
+
type: 'image' | 'audio' | 'video' | 'file';
|
|
420
|
+
url?: string;
|
|
421
|
+
data?: string;
|
|
422
|
+
name?: string;
|
|
423
|
+
};
|
|
424
|
+
};
|
|
425
|
+
};
|
|
426
|
+
export type ActionHistoryList = {
|
|
427
|
+
action: 'history.list';
|
|
428
|
+
payload: {
|
|
429
|
+
ChannelId: string;
|
|
430
|
+
params?: {
|
|
431
|
+
limit?: number;
|
|
432
|
+
before?: string;
|
|
433
|
+
after?: string;
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
};
|
|
437
|
+
export type ActionPermissionGet = {
|
|
438
|
+
action: 'permission.get';
|
|
439
|
+
payload: {
|
|
440
|
+
ChannelId: string;
|
|
441
|
+
UserId: string;
|
|
442
|
+
};
|
|
443
|
+
};
|
|
444
|
+
export type ActionPermissionSet = {
|
|
445
|
+
action: 'permission.set';
|
|
446
|
+
payload: {
|
|
447
|
+
ChannelId: string;
|
|
448
|
+
UserId: string;
|
|
449
|
+
params: {
|
|
450
|
+
allow?: string;
|
|
451
|
+
deny?: string;
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
};
|
|
455
|
+
export type ActionReactionList = {
|
|
456
|
+
action: 'reaction.list';
|
|
457
|
+
payload: {
|
|
458
|
+
ChannelId: string;
|
|
459
|
+
MessageId: string;
|
|
460
|
+
EmojiId: string;
|
|
461
|
+
params?: {
|
|
462
|
+
limit?: number;
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
};
|
|
466
|
+
export type ActionMemberSearch = {
|
|
467
|
+
action: 'member.search';
|
|
468
|
+
payload: {
|
|
469
|
+
GuildId: string;
|
|
470
|
+
params: {
|
|
471
|
+
keyword: string;
|
|
472
|
+
limit?: number;
|
|
473
|
+
};
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
export type ActionChannelAnnounce = {
|
|
477
|
+
action: 'channel.announce';
|
|
478
|
+
payload: {
|
|
479
|
+
GuildId: string;
|
|
480
|
+
params: {
|
|
481
|
+
messageId?: string;
|
|
482
|
+
channelId?: string;
|
|
483
|
+
remove?: boolean;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
};
|
|
90
487
|
type base = {
|
|
91
488
|
actionId?: string;
|
|
92
489
|
DeviceId?: string;
|
|
93
490
|
};
|
|
94
|
-
export type Actions = (ActionMessageSend |
|
|
491
|
+
export type Actions = (ActionMessageSend | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageDelete | ActionMessageEdit | ActionMessagePin | ActionMessageUnpin | ActionMentionGet | ActionReactionAdd | ActionReactionRemove | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel | ActionMemberInfo | ActionMemberList | ActionMemberKick | ActionMemberBan | ActionMemberUnban | ActionGuildInfo | ActionGuildList | ActionChannelInfo | ActionChannelList | ActionChannelCreate | ActionChannelUpdate | ActionChannelDelete | ActionRoleList | ActionRoleCreate | ActionRoleUpdate | ActionRoleDelete | ActionRoleAssign | ActionRoleRemove | ActionMeInfo | ActionMeGuilds | ActionMeThreads | ActionMeFriends | ActionMessageGet | ActionGuildUpdate | ActionGuildLeave | ActionGuildMute | ActionMemberMute | ActionMemberAdmin | ActionMemberCard | ActionMemberTitle | ActionRequestFriend | ActionRequestGuild | ActionUserInfo | ActionMediaUpload | ActionMediaSendChannel | ActionMediaSendUser | ActionHistoryList | ActionPermissionGet | ActionPermissionSet | ActionReactionList | ActionMemberSearch | ActionChannelAnnounce | {
|
|
95
492
|
action: string;
|
|
96
493
|
payload: object;
|
|
97
494
|
}) & base;
|
|
@@ -2,6 +2,7 @@ import { Result } from '../../core/utils';
|
|
|
2
2
|
import { User } from '../event/base/user';
|
|
3
3
|
import { EventKeys, Events } from '../event/map';
|
|
4
4
|
import { DataEnums } from '../message';
|
|
5
|
+
import { GuildInfo, ChannelInfo, MemberInfo, RoleInfo, PaginationParams, PaginatedResult } from '../standard';
|
|
5
6
|
export type ClientAPIMessageResult = Result & {
|
|
6
7
|
data: {
|
|
7
8
|
id: string;
|
|
@@ -13,6 +14,78 @@ export type ClientAPI = {
|
|
|
13
14
|
use: {
|
|
14
15
|
send: <T extends EventKeys>(event: Events[T], val: DataEnums[]) => Promise<ClientAPIMessageResult[]>;
|
|
15
16
|
mention: <T extends EventKeys>(event: Events[T]) => Promise<User[]>;
|
|
17
|
+
delete?: (messageId: string, channelId?: string) => Promise<any>;
|
|
18
|
+
edit?: (channelId: string, messageId: string, val: DataEnums[]) => Promise<any>;
|
|
19
|
+
pin?: (channelId: string, messageId: string) => Promise<any>;
|
|
20
|
+
unpin?: (channelId: string, messageId: string) => Promise<any>;
|
|
21
|
+
file?: {
|
|
22
|
+
channel: (channelId: string, params: {
|
|
23
|
+
file: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
folder?: string;
|
|
26
|
+
}) => Promise<any>;
|
|
27
|
+
user: (userId: string, params: {
|
|
28
|
+
file: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
}) => Promise<any>;
|
|
31
|
+
};
|
|
32
|
+
forward?: {
|
|
33
|
+
channel: (channelId: string, params: any[]) => Promise<any>;
|
|
34
|
+
user: (userId: string, params: any[]) => Promise<any>;
|
|
35
|
+
};
|
|
36
|
+
reaction?: {
|
|
37
|
+
add: (channelId: string, messageId: string, emojiId: string) => Promise<any>;
|
|
38
|
+
remove: (channelId: string, messageId: string, emojiId: string) => Promise<any>;
|
|
39
|
+
};
|
|
40
|
+
member?: {
|
|
41
|
+
info: (guildId: string, userId: string) => Promise<MemberInfo | null>;
|
|
42
|
+
list: (guildId: string, params?: PaginationParams) => Promise<PaginatedResult<MemberInfo>>;
|
|
43
|
+
kick: (guildId: string, userId: string) => Promise<any>;
|
|
44
|
+
ban: (guildId: string, userId: string, params?: {
|
|
45
|
+
reason?: string;
|
|
46
|
+
duration?: number;
|
|
47
|
+
}) => Promise<any>;
|
|
48
|
+
unban: (guildId: string, userId: string) => Promise<any>;
|
|
49
|
+
};
|
|
50
|
+
guild?: {
|
|
51
|
+
info: (guildId: string) => Promise<GuildInfo | null>;
|
|
52
|
+
list: () => Promise<GuildInfo[]>;
|
|
53
|
+
};
|
|
54
|
+
channel?: {
|
|
55
|
+
info: (channelId: string) => Promise<ChannelInfo | null>;
|
|
56
|
+
list: (guildId: string) => Promise<ChannelInfo[]>;
|
|
57
|
+
create?: (guildId: string, params: {
|
|
58
|
+
name: string;
|
|
59
|
+
type?: string;
|
|
60
|
+
parentId?: string;
|
|
61
|
+
}) => Promise<ChannelInfo | null>;
|
|
62
|
+
update?: (channelId: string, params: {
|
|
63
|
+
name?: string;
|
|
64
|
+
topic?: string;
|
|
65
|
+
position?: number;
|
|
66
|
+
}) => Promise<any>;
|
|
67
|
+
delete?: (channelId: string) => Promise<any>;
|
|
68
|
+
};
|
|
69
|
+
role?: {
|
|
70
|
+
list: (guildId: string) => Promise<RoleInfo[]>;
|
|
71
|
+
create?: (guildId: string, params: {
|
|
72
|
+
name: string;
|
|
73
|
+
color?: number;
|
|
74
|
+
permissions?: string;
|
|
75
|
+
}) => Promise<RoleInfo | null>;
|
|
76
|
+
update?: (roleId: string, guildId: string, params: {
|
|
77
|
+
name?: string;
|
|
78
|
+
color?: number;
|
|
79
|
+
permissions?: string;
|
|
80
|
+
}) => Promise<any>;
|
|
81
|
+
delete?: (roleId: string, guildId: string) => Promise<any>;
|
|
82
|
+
assign: (guildId: string, userId: string, roleId: string) => Promise<any>;
|
|
83
|
+
remove: (guildId: string, userId: string, roleId: string) => Promise<any>;
|
|
84
|
+
};
|
|
85
|
+
me?: {
|
|
86
|
+
info: () => Promise<User | null>;
|
|
87
|
+
guilds?: () => Promise<GuildInfo[]>;
|
|
88
|
+
};
|
|
16
89
|
};
|
|
17
90
|
active: {
|
|
18
91
|
send: {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { User } from './event/base/user';
|
|
2
|
+
export type GuildInfo = {
|
|
3
|
+
GuildId: string;
|
|
4
|
+
GuildName?: string;
|
|
5
|
+
GuildIcon?: string;
|
|
6
|
+
GuildOwnerId?: string;
|
|
7
|
+
MemberCount?: number;
|
|
8
|
+
Description?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ChannelType = 'text' | 'voice' | 'category' | 'announcement' | 'stage' | 'forum' | 'thread' | 'unknown';
|
|
11
|
+
export type ChannelInfo = {
|
|
12
|
+
ChannelId: string;
|
|
13
|
+
ChannelName?: string;
|
|
14
|
+
ChannelType?: ChannelType;
|
|
15
|
+
GuildId?: string;
|
|
16
|
+
Topic?: string;
|
|
17
|
+
Position?: number;
|
|
18
|
+
ParentId?: string;
|
|
19
|
+
};
|
|
20
|
+
export type MemberInfo = User & {
|
|
21
|
+
Nickname?: string;
|
|
22
|
+
GuildId?: string;
|
|
23
|
+
Roles?: string[];
|
|
24
|
+
JoinedAt?: number;
|
|
25
|
+
};
|
|
26
|
+
export type RoleInfo = {
|
|
27
|
+
RoleId: string;
|
|
28
|
+
RoleName?: string;
|
|
29
|
+
Color?: number;
|
|
30
|
+
Position?: number;
|
|
31
|
+
Permissions?: string;
|
|
32
|
+
Mentionable?: boolean;
|
|
33
|
+
Managed?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type ReactionInfo = {
|
|
36
|
+
EmojiId: string;
|
|
37
|
+
EmojiName?: string;
|
|
38
|
+
Count?: number;
|
|
39
|
+
IsMe?: boolean;
|
|
40
|
+
};
|
|
41
|
+
export type PaginationParams = {
|
|
42
|
+
Limit?: number;
|
|
43
|
+
After?: string;
|
|
44
|
+
Before?: string;
|
|
45
|
+
};
|
|
46
|
+
export type PaginatedResult<T> = {
|
|
47
|
+
Items: T[];
|
|
48
|
+
Total?: number;
|
|
49
|
+
HasMore?: boolean;
|
|
50
|
+
NextCursor?: string;
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alemonjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.45",
|
|
4
4
|
"description": "bot script",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,5 +68,6 @@
|
|
|
68
68
|
"repository": {
|
|
69
69
|
"type": "git",
|
|
70
70
|
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
71
|
-
}
|
|
72
|
-
|
|
71
|
+
},
|
|
72
|
+
"gitHead": "743b70375f728a1584ae149bbadcd04378540ade"
|
|
73
|
+
}
|