alemonjs 2.1.94 → 2.1.96

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.
@@ -9,10 +9,21 @@ export declare class MessageDirect {
9
9
  SpaceId: string;
10
10
  format: Format | DataEnums[];
11
11
  replyId?: string;
12
+ BotId?: string;
12
13
  }): Promise<Result[]>;
13
14
  sendToUser(params: {
14
15
  OpenID: string;
15
16
  format: Format | DataEnums[];
17
+ BotId?: string;
18
+ }): Promise<Result[]>;
19
+ sendToTarget(params: {
20
+ target: {
21
+ scope: 'group' | 'c2c' | 'channel' | 'direct';
22
+ targetId: string;
23
+ BotId?: string;
24
+ };
25
+ format: Format | DataEnums[];
26
+ replyId?: string;
16
27
  }): Promise<Result[]>;
17
28
  }
18
29
  export declare const sendToChannel: (SpaceId: string, data: DataEnums[]) => Promise<Result[]>;
@@ -46,6 +46,7 @@ class MessageDirect {
46
46
  action: 'message.send.channel',
47
47
  payload: {
48
48
  ChannelId: params.SpaceId,
49
+ BotId: params.BotId,
49
50
  params: {
50
51
  format: Array.isArray(params.format) ? params.format : params.format.value,
51
52
  replyId: params?.replyId
@@ -75,6 +76,7 @@ class MessageDirect {
75
76
  action: 'message.send.user',
76
77
  payload: {
77
78
  UserId: params.OpenID,
79
+ BotId: params.BotId,
78
80
  params: {
79
81
  format: Array.isArray(params.format) ? params.format : params.format.value
80
82
  }
@@ -88,6 +90,30 @@ class MessageDirect {
88
90
  throw error;
89
91
  }
90
92
  }
93
+ async sendToTarget(params) {
94
+ if (!params.target?.targetId) {
95
+ throw new Error('Invalid targetId: targetId must be a non-empty string');
96
+ }
97
+ markEventSendAttempt();
98
+ try {
99
+ const results = await sendAction({
100
+ action: 'message.send.target',
101
+ payload: {
102
+ target: params.target,
103
+ params: {
104
+ format: Array.isArray(params.format) ? params.format : params.format.value,
105
+ replyId: params.replyId
106
+ }
107
+ }
108
+ });
109
+ recordEventSendResults(results, undefined);
110
+ return results;
111
+ }
112
+ catch (error) {
113
+ markEventSendFailure(error);
114
+ throw error;
115
+ }
116
+ }
91
117
  }
92
118
  const sendToChannel = (SpaceId, data) => {
93
119
  return MessageDirect.create().sendToChannel({ SpaceId, format: data, replyId: undefined });
@@ -2,6 +2,8 @@ import { DataMention, DataText, DataImageURL, DataImageFile, DataButtonRow, Data
2
2
  export declare class FormatButtonGroup {
3
3
  #private;
4
4
  get value(): DataButtonGroup;
5
+ smallButton(): this;
6
+ setOptions(options?: DataButtonGroup['options']): this;
5
7
  absorb(group: FormatButtonGroup): this;
6
8
  addRow(): this;
7
9
  addButton(title: string, data: DataButton['options']['data'], options?: Omit<DataButton['options'], 'data'>): this;
@@ -1,13 +1,26 @@
1
1
  class FormatButtonGroup {
2
2
  #rows = [];
3
3
  #currentRow = null;
4
+ #options;
4
5
  get value() {
5
6
  this.#flush();
6
7
  return {
7
8
  type: 'BT.group',
8
- value: this.#rows
9
+ value: this.#rows,
10
+ ...(this.#options ? { options: this.#options } : {})
9
11
  };
10
12
  }
13
+ smallButton() {
14
+ this.#options = {
15
+ ...this.#options,
16
+ smallButton: true
17
+ };
18
+ return this;
19
+ }
20
+ setOptions(options) {
21
+ this.#options = options;
22
+ return this;
23
+ }
11
24
  #flush() {
12
25
  if (this.#currentRow && this.#currentRow.length > 0) {
13
26
  this.#rows.push({
@@ -0,0 +1,6 @@
1
+ import { ConnectionStatus, Result } from './common';
2
+ export declare const useConnection: () => readonly [{
3
+ readonly getStatus: (params?: {
4
+ BotId?: string;
5
+ }) => Promise<Result<ConnectionStatus>>;
6
+ }];
@@ -0,0 +1,35 @@
1
+ import { ResultCode } from '../../common/variable.js';
2
+ import '../runtime/store.js';
3
+ import '../../common/utils.js';
4
+ import { sendAction } from '../runtime/cbp/processor/actions.js';
5
+ import 'fs';
6
+ import 'path';
7
+ import 'yaml';
8
+ import '../../common/logger.js';
9
+ import { createResult } from '../../common/result.js';
10
+ import 'net';
11
+ import 'v8';
12
+ import 'os';
13
+ import 'flatted';
14
+ import '../../common/cbp/runtime.js';
15
+ import 'ws';
16
+ import '../runtime/hook-event-context.js';
17
+
18
+ const useConnection = () => {
19
+ const getStatus = async (params) => {
20
+ try {
21
+ const results = await sendAction({
22
+ action: 'connection.status',
23
+ payload: params || {}
24
+ });
25
+ const result = results.find(item => item.code === ResultCode.Ok);
26
+ return result || createResult(ResultCode.Warn, 'Connection status is not supported', null);
27
+ }
28
+ catch {
29
+ return createResult(ResultCode.Fail, 'Failed to get connection status', null);
30
+ }
31
+ };
32
+ return [{ getStatus }];
33
+ };
34
+
35
+ export { useConnection };
@@ -1,8 +1,10 @@
1
1
  export * from './announce';
2
2
  export * from './channel';
3
+ export * from './connection';
3
4
  export * from './client';
4
5
  export * from './guild';
5
6
  export * from './history';
7
+ export * from './interaction';
6
8
  export * from './media';
7
9
  export * from './me';
8
10
  export * from './member';
@@ -1,8 +1,10 @@
1
1
  export { useAnnounce } from './announce.js';
2
2
  export { useChannel } from './channel.js';
3
+ export { useConnection } from './connection.js';
3
4
  export { useClient } from './client.js';
4
5
  export { useGuild } from './guild.js';
5
6
  export { useHistory } from './history.js';
7
+ export { useInteraction } from './interaction.js';
6
8
  export { useMedia } from './media.js';
7
9
  export { useMe } from './me.js';
8
10
  export { useMember } from './member.js';
@@ -0,0 +1,8 @@
1
+ import { ActionTarget, EventKeys, Events, Result } from './common';
2
+ export declare const useInteraction: <T extends EventKeys>(event?: Events[T]) => readonly [{
3
+ readonly ack: (params?: {
4
+ InteractionId?: string;
5
+ code?: number;
6
+ target?: ActionTarget;
7
+ }) => Promise<Result>;
8
+ }];
@@ -0,0 +1,35 @@
1
+ import { getEventOrThrow } from './common.js';
2
+ import { createResult } from '../../common/result.js';
3
+ import '../../common/utils.js';
4
+ import { ResultCode } from '../../common/variable.js';
5
+ import { sendAction } from '../runtime/cbp/processor/actions.js';
6
+
7
+ const useInteraction = (event) => {
8
+ const valueEvent = getEventOrThrow(event);
9
+ const ack = async (params) => {
10
+ const interactionId = params?.InteractionId || valueEvent.InteractionId;
11
+ const eventTarget = valueEvent.Target;
12
+ const target = params?.target || eventTarget;
13
+ if (!interactionId) {
14
+ return createResult(ResultCode.FailParams, 'Missing InteractionId', null);
15
+ }
16
+ try {
17
+ const results = await sendAction({
18
+ action: 'interaction.ack',
19
+ payload: {
20
+ InteractionId: interactionId,
21
+ ...(target && { target }),
22
+ params: { code: params?.code }
23
+ }
24
+ });
25
+ const result = results.find(item => item.code === ResultCode.Ok);
26
+ return result || createResult(ResultCode.Warn, 'Interaction acknowledgement is not supported', null);
27
+ }
28
+ catch {
29
+ return createResult(ResultCode.Fail, 'Failed to acknowledge interaction', null);
30
+ }
31
+ };
32
+ return [{ ack }];
33
+ };
34
+
35
+ export { useInteraction };
@@ -4,20 +4,46 @@ export declare const useMedia: <T extends EventKeys>(event?: Events[T]) => reado
4
4
  type: "file" | "image" | "audio" | "video";
5
5
  url?: string;
6
6
  data?: string;
7
+ filePath?: string;
8
+ fileId?: string;
7
9
  name?: string;
10
+ content?: string;
11
+ } & {
12
+ target?: ActionTarget;
8
13
  }) => Promise<Result>;
9
14
  sendChannel: (params: {
10
15
  type: "file" | "image" | "audio" | "video";
11
16
  url?: string;
12
17
  data?: string;
18
+ filePath?: string;
19
+ fileId?: string;
13
20
  name?: string;
21
+ content?: string;
22
+ } & {
14
23
  channelId?: string;
24
+ BotId?: string;
15
25
  }) => Promise<Result>;
16
26
  sendUser: (params: {
27
+ type: "file" | "image" | "audio" | "video";
28
+ url?: string;
29
+ data?: string;
30
+ filePath?: string;
31
+ fileId?: string;
32
+ name?: string;
33
+ content?: string;
34
+ } & {
17
35
  userId: string;
36
+ BotId?: string;
37
+ }) => Promise<Result>;
38
+ send: (params: {
18
39
  type: "file" | "image" | "audio" | "video";
19
40
  url?: string;
20
41
  data?: string;
42
+ filePath?: string;
43
+ fileId?: string;
21
44
  name?: string;
45
+ content?: string;
46
+ } & {
47
+ target: ActionTarget;
22
48
  }) => Promise<Result>;
23
49
  }];
@@ -6,11 +6,17 @@ import { sendAction } from '../runtime/cbp/processor/actions.js';
6
6
 
7
7
  const useMedia = (event) => {
8
8
  const valueEvent = getEventOrThrow(event);
9
+ const validateSource = (params) => {
10
+ const count = [params.url, params.data, params.filePath, params.fileId].filter(value => value !== undefined).length;
11
+ return count === 1;
12
+ };
9
13
  const upload = async (params) => {
14
+ if (!validateSource(params))
15
+ return createResult(ResultCode.FailParams, 'Provide exactly one media source', null);
10
16
  try {
11
17
  const results = await sendAction({
12
18
  action: 'media.upload',
13
- payload: { params }
19
+ payload: { target: params.target, params }
14
20
  });
15
21
  const result = results.find(item => item.code === ResultCode.Ok);
16
22
  return result || createResult(ResultCode.Warn, 'Media upload not supported or failed', null);
@@ -27,7 +33,7 @@ const useMedia = (event) => {
27
33
  try {
28
34
  const results = await sendAction({
29
35
  action: 'media.send.channel',
30
- payload: { ChannelId: cid, params: { type: params.type, url: params.url, data: params.data, name: params.name } }
36
+ payload: { ChannelId: cid, BotId: params.BotId, params }
31
37
  });
32
38
  const result = results.find(item => item.code === ResultCode.Ok);
33
39
  return result || createResult(ResultCode.Warn, 'Media send not supported or failed', null);
@@ -43,7 +49,7 @@ const useMedia = (event) => {
43
49
  try {
44
50
  const results = await sendAction({
45
51
  action: 'media.send.user',
46
- payload: { UserId: params.userId, params: { type: params.type, url: params.url, data: params.data, name: params.name } }
52
+ payload: { UserId: params.userId, BotId: params.BotId, params }
47
53
  });
48
54
  const result = results.find(item => item.code === ResultCode.Ok);
49
55
  return result || createResult(ResultCode.Warn, 'Media send not supported or failed', null);
@@ -52,10 +58,32 @@ const useMedia = (event) => {
52
58
  return createResult(ResultCode.Fail, 'Failed to send media to user', null);
53
59
  }
54
60
  };
61
+ const send = async (params) => {
62
+ if (!params.target?.targetId) {
63
+ return createResult(ResultCode.FailParams, 'Missing targetId', null);
64
+ }
65
+ if (!validateSource(params))
66
+ return createResult(ResultCode.FailParams, 'Provide exactly one media source', null);
67
+ try {
68
+ const results = await sendAction({
69
+ action: 'media.send',
70
+ payload: {
71
+ target: params.target,
72
+ params
73
+ }
74
+ });
75
+ const result = results.find(item => item.code === ResultCode.Ok);
76
+ return result || createResult(ResultCode.Warn, 'Media send not supported or failed', null);
77
+ }
78
+ catch {
79
+ return createResult(ResultCode.Fail, 'Failed to send media', null);
80
+ }
81
+ };
55
82
  const media = {
56
83
  upload,
57
84
  sendChannel,
58
- sendUser
85
+ sendUser,
86
+ send
59
87
  };
60
88
  return [media];
61
89
  };
@@ -6,9 +6,11 @@ export { defineRouter, lazy, runHandler } from './define-router.js';
6
6
  export { Expose, clearAllExpose, disposeExpose, registerExpose } from './expose.js';
7
7
  export { useAnnounce } from './hooks/announce.js';
8
8
  export { useChannel } from './hooks/channel.js';
9
+ export { useConnection } from './hooks/connection.js';
9
10
  export { useClient } from './hooks/client.js';
10
11
  export { useGuild } from './hooks/guild.js';
11
12
  export { useHistory } from './hooks/history.js';
13
+ export { useInteraction } from './hooks/interaction.js';
12
14
  export { useMedia } from './hooks/media.js';
13
15
  export { useMe } from './hooks/me.js';
14
16
  export { useMember } from './hooks/member.js';
@@ -689,7 +689,7 @@ class Router {
689
689
  const md = Format.createMarkdown();
690
690
  const format = Format.create();
691
691
  const routeEntry = (result.eventName && result.matchedPath
692
- ? this.routes.get(result.eventName)?.one.get(result.matchedPath) ?? this.routes.get(result.eventName)?.two.get(result.matchedPath)
692
+ ? (this.routes.get(result.eventName)?.one.get(result.matchedPath) ?? this.routes.get(result.eventName)?.two.get(result.matchedPath))
693
693
  : undefined) ?? undefined;
694
694
  const description = formatRouteDescription(routeEntry?.config.description);
695
695
  const schemaHints = buildSchemaHints(routeEntry?.config.schema);
package/lib/index.js CHANGED
@@ -60,9 +60,11 @@ export { registerAppDir, scheduleCancel, scheduleCancelAll, scheduleCancelByApp,
60
60
  export { useAnnounce } from './application/hooks/announce.js';
61
61
  export { useChannel } from './application/hooks/channel.js';
62
62
  export { useClient } from './application/hooks/client.js';
63
+ export { useConnection } from './application/hooks/connection.js';
63
64
  export { useGuild } from './application/hooks/guild.js';
64
65
  export { useHeartbeat } from './common/cbp/heartbeat.js';
65
66
  export { useHistory } from './application/hooks/history.js';
67
+ export { useInteraction } from './application/hooks/interaction.js';
66
68
  export { useMe } from './application/hooks/me.js';
67
69
  export { useMedia } from './application/hooks/media.js';
68
70
  export { useMember } from './application/hooks/member.js';
@@ -1,4 +1,4 @@
1
- import { Events, EventKeys, EventBuilder, ReservedEventKeys, User, Guild, Channel, Message, MessageText, MessageMedia, MessageOpen, Platform } from '../types';
1
+ import { Events, EventKeys, EventBuilder, ReservedEventKeys, User, Guild, Channel, Message, MessageText, MessageMedia, MessageOpen, Platform, Interaction } from '../types';
2
2
  export declare class FormatEvent<T extends EventKeys = EventKeys> {
3
3
  #private;
4
4
  private constructor();
@@ -11,6 +11,7 @@ export declare class FormatEvent<T extends EventKeys = EventKeys> {
11
11
  addText(params: MessageText): this;
12
12
  addMedia(params: MessageMedia): this;
13
13
  addOpen(params: MessageOpen): this;
14
+ addInteraction(params: Interaction): this;
14
15
  add<E extends Record<string, unknown>>(fields: {
15
16
  [K in keyof E]: K extends ReservedEventKeys ? never : E[K];
16
17
  }): this;
@@ -65,6 +65,14 @@ class FormatEvent {
65
65
  });
66
66
  return this;
67
67
  }
68
+ addInteraction(params) {
69
+ Object.assign(this.#data, {
70
+ InteractionId: params.InteractionId,
71
+ ...(params.InteractionData !== undefined && { InteractionData: params.InteractionData }),
72
+ ...(params.Target !== undefined && { Target: params.Target })
73
+ });
74
+ return this;
75
+ }
68
76
  add(fields) {
69
77
  for (const key of Object.keys(fields)) {
70
78
  this.#data[`_${key}`] = fields[key];
@@ -1,6 +1,12 @@
1
1
  import { DataEnums } from './message';
2
2
  import { PaginationParams } from './standard';
3
- export type MessageActionName = 'message.send' | 'message.send.channel' | 'message.send.user' | 'message.delete' | 'message.edit' | 'message.pin' | 'message.unpin' | 'message.forward.user' | 'message.forward.channel' | 'message.get' | 'message.intent';
3
+ export type ActionTargetScope = 'group' | 'c2c' | 'channel' | 'direct';
4
+ export type ActionTarget = {
5
+ scope: ActionTargetScope;
6
+ targetId: string;
7
+ BotId?: string;
8
+ };
9
+ export type MessageActionName = 'message.send' | 'message.send.channel' | 'message.send.user' | 'message.send.target' | 'message.delete' | 'message.edit' | 'message.pin' | 'message.unpin' | 'message.forward.user' | 'message.forward.channel' | 'message.get' | 'message.intent';
4
10
  export type MentionActionName = 'mention.get';
5
11
  export type ReactionActionName = 'reaction.add' | 'reaction.remove' | 'reaction.list';
6
12
  export type FileActionName = 'file.send.channel' | 'file.send.user';
@@ -11,10 +17,12 @@ export type RoleActionName = 'role.list' | 'role.create' | 'role.update' | 'role
11
17
  export type MeActionName = 'me.info' | 'me.guilds' | 'me.threads' | 'me.friends';
12
18
  export type RequestActionName = 'request.friend' | 'request.guild';
13
19
  export type UserActionName = 'user.info';
14
- export type MediaActionName = 'media.upload' | 'media.send.channel' | 'media.send.user';
20
+ export type MediaActionName = 'media.upload' | 'media.send.channel' | 'media.send.user' | 'media.send';
21
+ export type InteractionActionName = 'interaction.ack';
22
+ export type ConnectionActionName = 'connection.status';
15
23
  export type HistoryActionName = 'history.list';
16
24
  export type PermissionActionName = 'permission.get' | 'permission.set';
17
- export type StandardActionName = MessageActionName | MentionActionName | ReactionActionName | FileActionName | MemberActionName | GuildActionName | ChannelActionName | RoleActionName | MeActionName | RequestActionName | UserActionName | MediaActionName | HistoryActionName | PermissionActionName;
25
+ export type StandardActionName = MessageActionName | MentionActionName | ReactionActionName | FileActionName | MemberActionName | GuildActionName | ChannelActionName | RoleActionName | MeActionName | RequestActionName | UserActionName | MediaActionName | InteractionActionName | ConnectionActionName | HistoryActionName | PermissionActionName;
18
26
  export type ActionMessageSend = {
19
27
  action: 'message.send';
20
28
  payload: {
@@ -28,6 +36,7 @@ export type ActionMessageSendChannel = {
28
36
  action: 'message.send.channel';
29
37
  payload: {
30
38
  ChannelId: string;
39
+ BotId?: string;
31
40
  params: {
32
41
  format?: DataEnums[];
33
42
  };
@@ -37,8 +46,19 @@ export type ActionMessageSendUser = {
37
46
  action: 'message.send.user';
38
47
  payload: {
39
48
  UserId: string;
49
+ BotId?: string;
50
+ params: {
51
+ format?: DataEnums[];
52
+ };
53
+ };
54
+ };
55
+ export type ActionMessageSendTarget = {
56
+ action: 'message.send.target';
57
+ payload: {
58
+ target: ActionTarget;
40
59
  params: {
41
60
  format?: DataEnums[];
61
+ replyId?: string;
42
62
  };
43
63
  };
44
64
  };
@@ -53,9 +73,26 @@ export type ActionMessageDelete = {
53
73
  payload: {
54
74
  MessageId: string;
55
75
  ChannelId?: string;
76
+ target?: ActionTarget;
56
77
  event?: any;
57
78
  };
58
79
  };
80
+ export type ActionInteractionAck = {
81
+ action: 'interaction.ack';
82
+ payload: {
83
+ InteractionId: string;
84
+ target?: ActionTarget;
85
+ params?: {
86
+ code?: number;
87
+ };
88
+ };
89
+ };
90
+ export type ActionConnectionStatus = {
91
+ action: 'connection.status';
92
+ payload: {
93
+ BotId?: string;
94
+ };
95
+ };
59
96
  export type ActionMessageEdit = {
60
97
  action: 'message.edit';
61
98
  payload: {
@@ -407,39 +444,43 @@ export type ActionUserInfo = {
407
444
  UserId: string;
408
445
  };
409
446
  };
447
+ export type ActionMediaParams = {
448
+ type: 'image' | 'audio' | 'video' | 'file';
449
+ url?: string;
450
+ data?: string;
451
+ filePath?: string;
452
+ fileId?: string;
453
+ name?: string;
454
+ content?: string;
455
+ };
410
456
  export type ActionMediaUpload = {
411
457
  action: 'media.upload';
412
458
  payload: {
413
- params: {
414
- type: 'image' | 'audio' | 'video' | 'file';
415
- url?: string;
416
- data?: string;
417
- name?: string;
418
- };
459
+ target?: ActionTarget;
460
+ params: ActionMediaParams;
419
461
  };
420
462
  };
421
463
  export type ActionMediaSendChannel = {
422
464
  action: 'media.send.channel';
423
465
  payload: {
424
466
  ChannelId: string;
425
- params: {
426
- type: 'image' | 'audio' | 'video' | 'file';
427
- url?: string;
428
- data?: string;
429
- name?: string;
430
- };
467
+ BotId?: string;
468
+ params: ActionMediaParams;
431
469
  };
432
470
  };
433
471
  export type ActionMediaSendUser = {
434
472
  action: 'media.send.user';
435
473
  payload: {
436
474
  UserId: string;
437
- params: {
438
- type: 'image' | 'audio' | 'video' | 'file';
439
- url?: string;
440
- data?: string;
441
- name?: string;
442
- };
475
+ BotId?: string;
476
+ params: ActionMediaParams;
477
+ };
478
+ };
479
+ export type ActionMediaSend = {
480
+ action: 'media.send';
481
+ payload: {
482
+ target: ActionTarget;
483
+ params: ActionMediaParams;
443
484
  };
444
485
  };
445
486
  export type ActionHistoryList = {
@@ -507,7 +548,7 @@ type base = {
507
548
  actionId?: string;
508
549
  DeviceId?: string;
509
550
  };
510
- export type Actions = (ActionMessageSend | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageDelete | ActionMessageEdit | ActionMessagePin | ActionMessageUnpin | ActionMentionGet | ActionReactionAdd | ActionReactionRemove | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel | ActionMessageIntent | 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 | {
551
+ export type Actions = (ActionMessageSend | ActionMessageSendChannel | ActionMessageSendUser | ActionMessageSendTarget | ActionMessageDelete | ActionInteractionAck | ActionConnectionStatus | ActionMessageEdit | ActionMessagePin | ActionMessageUnpin | ActionMentionGet | ActionReactionAdd | ActionReactionRemove | ActionFileSendChannel | ActionFileSendUser | ActionMessageForwardUser | ActionMessageForwardChannel | ActionMessageIntent | 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 | ActionMediaSend | ActionHistoryList | ActionPermissionGet | ActionPermissionSet | ActionReactionList | ActionMemberSearch | ActionChannelAnnounce | {
511
552
  action: string;
512
553
  payload: object;
513
554
  }) & base;
@@ -0,0 +1,15 @@
1
+ export type ConnectionState = 'idle' | 'connecting' | 'ready' | 'reconnecting' | 'offline' | 'stopped';
2
+ export type ConnectionBotStatus = {
3
+ BotId: string;
4
+ state: ConnectionState;
5
+ transport?: string | null;
6
+ reconnectAttempts?: number;
7
+ heartbeatAcknowledged?: boolean;
8
+ resumed?: boolean;
9
+ lastError?: string;
10
+ };
11
+ export type ConnectionStatus = {
12
+ Platform?: string;
13
+ state: ConnectionState;
14
+ bots: ConnectionBotStatus[];
15
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,6 @@
1
+ export type Interaction = {
2
+ InteractionId: string;
3
+ InteractionData?: string;
4
+ Target?: ActionTarget;
5
+ };
6
+ import type { ActionTarget } from '../../actions';
@@ -3,8 +3,9 @@ import { Message, MessageText, MessageMedia, MessageOpen } from './base/message'
3
3
  import { Platform } from './base/platform';
4
4
  import { User } from './base/user';
5
5
  import { AutoFields } from './base/auto';
6
+ import { Interaction } from './base/interaction';
6
7
  import { EventKeys, Events } from './map';
7
- export type ReservedEventKeys = keyof Guild | keyof Channel | keyof User | keyof Message | keyof MessageText | keyof MessageMedia | keyof MessageOpen | keyof Platform | keyof AutoFields | 'name' | 'Timestamp';
8
+ export type ReservedEventKeys = keyof Guild | keyof Channel | keyof User | keyof Message | keyof MessageText | keyof MessageMedia | keyof MessageOpen | keyof Platform | keyof Interaction | keyof AutoFields | 'name' | 'Timestamp';
8
9
  type GuildMethods<T extends EventKeys> = Events[T] extends Guild ? {
9
10
  addGuild(params: Guild): EventBuilder<T>;
10
11
  } : Record<string, never>;
@@ -26,11 +27,14 @@ type MediaMethods<T extends EventKeys> = Events[T] extends MessageMedia ? {
26
27
  type OpenMethods<T extends EventKeys> = Events[T] extends MessageOpen ? {
27
28
  addOpen(params: MessageOpen): EventBuilder<T>;
28
29
  } : Record<string, never>;
30
+ type InteractionMethods<T extends EventKeys> = Events[T] extends Interaction ? {
31
+ addInteraction(params: Interaction): EventBuilder<T>;
32
+ } : Record<string, never>;
29
33
  export type EventBuilder<T extends EventKeys> = {
30
34
  addPlatform(params: Platform): EventBuilder<T>;
31
35
  add<E extends Record<string, unknown>>(fields: {
32
36
  [K in keyof E]: K extends ReservedEventKeys ? never : E[K];
33
37
  }): EventBuilder<T>;
34
38
  readonly value: Events[T];
35
- } & GuildMethods<T> & ChannelMethods<T> & UserMethods<T> & MessageMethods<T> & TextMethods<T> & MediaMethods<T> & OpenMethods<T>;
39
+ } & GuildMethods<T> & ChannelMethods<T> & UserMethods<T> & MessageMethods<T> & TextMethods<T> & MediaMethods<T> & OpenMethods<T> & InteractionMethods<T>;
36
40
  export {};
@@ -2,10 +2,11 @@ import { Guild, Channel } from '../base/guild';
2
2
  import { Message, MessageOpen, MessageText } from '../base/message';
3
3
  import { User } from '../base/user';
4
4
  import { Platform } from '../base/platform';
5
+ import { Interaction } from '../base/interaction';
5
6
  import { Expansion } from '../base/expansion';
6
- export type PrivateEventInteractionCreate = MessageText & MessageOpen & Platform & Message & User & {
7
+ export type PrivateEventInteractionCreate = MessageText & Interaction & MessageOpen & Platform & Message & User & {
7
8
  name: 'private.interaction.create';
8
9
  } & Expansion;
9
- export type PublicEventInteractionCreate = MessageText & MessageOpen & Platform & Guild & Channel & Message & User & {
10
+ export type PublicEventInteractionCreate = MessageText & Interaction & MessageOpen & Platform & Guild & Channel & Message & User & {
10
11
  name: 'interaction.create';
11
12
  } & Expansion;
@@ -5,6 +5,7 @@ export * from './event/base/message';
5
5
  export * from './event/base/platform';
6
6
  export * from './event/base/user';
7
7
  export * from './event/base/auto';
8
+ export * from './event/base/interaction';
8
9
  export * from './event/channel/index';
9
10
  export * from './event/guild/index';
10
11
  export * from './event/interaction/index';
@@ -28,5 +29,6 @@ export * from './subscribe';
28
29
  export * from './schedule';
29
30
  export * from './standard';
30
31
  export * from './actions';
32
+ export * from './connection';
31
33
  export * from './apis';
32
34
  export * from './run';
@@ -17,6 +17,14 @@ export type DataButton = {
17
17
  rawData: {
18
18
  [key: string]: any;
19
19
  };
20
+ modal?: {
21
+ content?: string;
22
+ confirmText?: string;
23
+ cancelText?: string;
24
+ };
25
+ anchor?: number;
26
+ clickLimit?: number;
27
+ atBotShowChannelList?: boolean;
20
28
  };
21
29
  };
22
30
  export type DataButtonRow = {
@@ -26,4 +34,8 @@ export type DataButtonRow = {
26
34
  export type DataButtonGroup = {
27
35
  type: 'ButtonGroup' | 'BT.group';
28
36
  value: DataButtonRow[];
37
+ options?: {
38
+ smallButton?: boolean;
39
+ rawData?: Record<string, any>;
40
+ };
29
41
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.94",
3
+ "version": "2.1.96",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
@@ -87,5 +87,5 @@
87
87
  "type": "git",
88
88
  "url": "https://github.com/lemonade-lab/alemonjs.git"
89
89
  },
90
- "gitHead": "edc7f9c5c75f4f5eaf527bb1dfdb31882bde6d6c"
90
+ "gitHead": "6c93b0455b8db78ffa1a83becc1c2de19ba544db"
91
91
  }