@alemonjs/discord 0.2.9 → 2.1.0-alpha.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.
Files changed (53) hide show
  1. package/dist/assets/index.js +3 -3
  2. package/lib/env.js +1 -0
  3. package/lib/index.d.ts +2 -7
  4. package/lib/index.js +189 -271
  5. package/lib/sdk/api.d.ts +972 -0
  6. package/lib/sdk/{platform/discord/sdk/api.js → api.js} +27 -10
  7. package/lib/sdk/config.js +10 -0
  8. package/lib/sdk/intents.js +154 -0
  9. package/lib/sdk/message/CHANNEL_TOPIC_UPDATE.d.ts +11 -0
  10. package/lib/sdk/message/CHANNEL_UPDATE.d.ts +48 -0
  11. package/lib/sdk/message/GUILD_MEMBER_ADD.d.ts +28 -0
  12. package/lib/sdk/message/GUILD_MEMBER_REMOVE.d.ts +18 -0
  13. package/lib/sdk/message/GUILD_MEMBER_UPDATE.d.ts +33 -0
  14. package/lib/sdk/message/INTERACTION_CREATE.d.ts +126 -0
  15. package/lib/sdk/message/MESSAGE_CREATE.d.ts +59 -0
  16. package/lib/sdk/message/MESSAGE_DELETE.d.ts +11 -0
  17. package/lib/sdk/message/MESSAGE_REACTION_ADD.d.ts +42 -0
  18. package/lib/sdk/message/MESSAGE_UPDATE.d.ts +56 -0
  19. package/lib/sdk/message/PRESENCE_UPDATE.d.ts +69 -0
  20. package/lib/sdk/message/READY.d.ts +9 -0
  21. package/lib/sdk/message/TYPING_START.d.ts +35 -0
  22. package/lib/sdk/message/VOICE_CHANNEL_STATUS_UPDATE.d.ts +10 -0
  23. package/lib/sdk/message/VOICE_STATE_UPDATE.d.ts +41 -0
  24. package/lib/sdk/message.d.ts +101 -0
  25. package/lib/sdk/types.d.ts +5 -0
  26. package/lib/sdk/types.js +25 -0
  27. package/lib/sdk/wss.d.ts +27 -0
  28. package/lib/sdk/{platform/discord/sdk/wss.js → wss.js} +14 -7
  29. package/lib/sdk/wss.types.d.ts +30 -0
  30. package/lib/send.js +132 -0
  31. package/package.json +4 -1
  32. package/lib/sdk/platform/discord/sdk/api.d.ts +0 -896
  33. package/lib/sdk/platform/discord/sdk/config.js +0 -29
  34. package/lib/sdk/platform/discord/sdk/intents.js +0 -36
  35. package/lib/sdk/platform/discord/sdk/message/CHANNEL_TOPIC_UPDATE.d.ts +0 -11
  36. package/lib/sdk/platform/discord/sdk/message/CHANNEL_UPDATE.d.ts +0 -48
  37. package/lib/sdk/platform/discord/sdk/message/GUILD_MEMBER_ADD.d.ts +0 -28
  38. package/lib/sdk/platform/discord/sdk/message/GUILD_MEMBER_REMOVE.d.ts +0 -18
  39. package/lib/sdk/platform/discord/sdk/message/GUILD_MEMBER_UPDATE.d.ts +0 -33
  40. package/lib/sdk/platform/discord/sdk/message/MESSAGE_CREATE.d.ts +0 -59
  41. package/lib/sdk/platform/discord/sdk/message/MESSAGE_DELETE.d.ts +0 -11
  42. package/lib/sdk/platform/discord/sdk/message/MESSAGE_REACTION_ADD.d.ts +0 -42
  43. package/lib/sdk/platform/discord/sdk/message/MESSAGE_UPDATE.d.ts +0 -56
  44. package/lib/sdk/platform/discord/sdk/message/PRESENCE_UPDATE.d.ts +0 -63
  45. package/lib/sdk/platform/discord/sdk/message/READY.d.ts +0 -9
  46. package/lib/sdk/platform/discord/sdk/message/TYPING_START.d.ts +0 -35
  47. package/lib/sdk/platform/discord/sdk/message/VOICE_CHANNEL_STATUS_UPDATE.d.ts +0 -10
  48. package/lib/sdk/platform/discord/sdk/message/VOICE_STATE_UPDATE.d.ts +0 -41
  49. package/lib/sdk/platform/discord/sdk/message.d.ts +0 -37
  50. package/lib/sdk/platform/discord/sdk/types.d.ts +0 -4
  51. package/lib/sdk/platform/discord/sdk/wss.d.ts +0 -27
  52. package/lib/sdk/platform/discord/sdk/wss.types.d.ts +0 -26
  53. /package/lib/sdk/core/{utils/from.js → from.js} +0 -0
@@ -1,29 +0,0 @@
1
- import { BaseConfig } from '../../../core/config.js';
2
-
3
- const config = new BaseConfig({
4
- token: '',
5
- intent: [
6
- 'MESSAGE_CONTENT', // 内容是基础
7
- //
8
- 'DIRECT_MESSAGES',
9
- 'DIRECT_MESSAGE_TYPING',
10
- 'DIRECT_MESSAGE_REACTIONS',
11
- //
12
- 'GUILDS',
13
- 'GUILD_MESSAGE_TYPING',
14
- 'REACTIONS',
15
- 'GUILD_MESSAGES',
16
- 'MEMBERS',
17
- //
18
- 'GUILD_MODERATION',
19
- 'GUILD_EMOJIS_AND_STICKERS',
20
- 'GUILD_INTEGRATIONS',
21
- 'GUILD_WEBHOOKS',
22
- 'GUILD_INVITES',
23
- 'GUILD_VOICE_STATES',
24
- 'GUILD_PRESENCES'
25
- ],
26
- shard: [0, 1]
27
- });
28
-
29
- export { config };
@@ -1,36 +0,0 @@
1
- const DCIntentsMap = {
2
- GUILDS: 1,
3
- MEMBERS: 2,
4
- GUILD_MODERATION: 4,
5
- GUILD_EMOJIS_AND_STICKERS: 8,
6
- GUILD_INTEGRATIONS: 16,
7
- GUILD_WEBHOOKS: 32,
8
- GUILD_INVITES: 64,
9
- GUILD_VOICE_STATES: 128,
10
- GUILD_PRESENCES: 256,
11
- GUILD_MESSAGES: 512,
12
- REACTIONS: 1024,
13
- GUILD_MESSAGE_TYPING: 2048,
14
- DIRECT_MESSAGES: 4096,
15
- DIRECT_MESSAGE_REACTIONS: 8192,
16
- DIRECT_MESSAGE_TYPING: 16384,
17
- MESSAGE_CONTENT: 32768,
18
- GUILD_SCHEDULED_EVENTS: 65536,
19
- AUTO_MODERATION_CONFIGURATION: 1048576,
20
- AUTO_MODERATION_EXECUTION: 2097152
21
- };
22
- /**
23
- *
24
- * @param intents
25
- * @returns
26
- */
27
- function getIntents(intents) {
28
- let result = 0;
29
- for (const intent of intents) {
30
- const i = DCIntentsMap[intent];
31
- result |= i;
32
- }
33
- return result;
34
- }
35
-
36
- export { getIntents };
@@ -1,11 +0,0 @@
1
- /**
2
- * 子频道
3
- * @param event
4
- */
5
- type CHANNEL_TOPIC_UPDATE_TYPE = {
6
- topic: null;
7
- id: string;
8
- guild_id: string;
9
- };
10
-
11
- export type { CHANNEL_TOPIC_UPDATE_TYPE };
@@ -1,48 +0,0 @@
1
- /**
2
- * 子频道更新
3
- * @param event
4
- */
5
- type CHANNEL_UPDATE_TYPE = {
6
- version: number;
7
- user_limit: number;
8
- type: number;
9
- rtc_region: null;
10
- rate_limit_per_user: number;
11
- position: number;
12
- permission_overwrites: [
13
- {
14
- type: number;
15
- id: string;
16
- deny: string;
17
- allow: string;
18
- },
19
- {
20
- type: number;
21
- id: string;
22
- deny: string;
23
- allow: string;
24
- },
25
- {
26
- type: number;
27
- id: string;
28
- deny: string;
29
- allow: string;
30
- },
31
- {
32
- type: number;
33
- id: string;
34
- deny: string;
35
- allow: string;
36
- }
37
- ];
38
- parent_id: null;
39
- nsfw: false;
40
- name: string;
41
- last_message_id: null;
42
- id: string;
43
- guild_id: string;
44
- flags: number;
45
- bitrate: number;
46
- };
47
-
48
- export type { CHANNEL_UPDATE_TYPE };
@@ -1,28 +0,0 @@
1
- /**
2
- * 频道 成员 增加
3
- */
4
- type GUILD_MEMBER_ADD_TYPE = {
5
- user: {
6
- username: string;
7
- public_flags: number;
8
- id: string;
9
- global_name: string;
10
- discriminator: string;
11
- avatar_decoration_data: null;
12
- avatar: string;
13
- };
14
- unusual_dm_activity_until: null;
15
- roles: any[];
16
- premium_since: null;
17
- pending: boolean;
18
- nick: null;
19
- mute: boolean;
20
- joined_at: string;
21
- guild_id: string;
22
- flags: number;
23
- deaf: boolean;
24
- communication_disabled_until: null;
25
- avatar: null;
26
- };
27
-
28
- export type { GUILD_MEMBER_ADD_TYPE };
@@ -1,18 +0,0 @@
1
- /**
2
- * 频道成员删除
3
- * @param event
4
- */
5
- type GUILD_MEMBER_REMOVE_TYPE = {
6
- user: {
7
- username: string;
8
- public_flags: number;
9
- id: string;
10
- global_name: string;
11
- discriminator: string;
12
- avatar_decoration_data: null;
13
- avatar: string;
14
- };
15
- guild_id: string;
16
- };
17
-
18
- export type { GUILD_MEMBER_REMOVE_TYPE };
@@ -1,33 +0,0 @@
1
- /**
2
- * 频道成员更新
3
- * @param event
4
- */
5
- type GUILD_MEMBER_UPDATE_TYPE = {
6
- user: {
7
- username: string;
8
- public_flags: number;
9
- id: string;
10
- global_name: string;
11
- display_name: string;
12
- discriminator: string;
13
- bot: boolean;
14
- avatar_decoration_data: {
15
- sku_id: string;
16
- asset: string;
17
- };
18
- avatar: string;
19
- };
20
- roles: string[];
21
- premium_since: null;
22
- pending: boolean;
23
- nick: null;
24
- mute: boolean;
25
- joined_at: string;
26
- guild_id: string;
27
- flags: number;
28
- deaf: boolean;
29
- communication_disabled_until: null;
30
- avatar: null;
31
- };
32
-
33
- export type { GUILD_MEMBER_UPDATE_TYPE };
@@ -1,59 +0,0 @@
1
- /**
2
- * 基础消息
3
- * @param event
4
- */
5
- type MESSAGE_CREATE_TYPE = {
6
- type: number;
7
- tts: boolean;
8
- timestamp: string;
9
- referenced_message: null;
10
- pinned: boolean;
11
- nonce: string;
12
- mentions: {
13
- username: string;
14
- public_flags: number;
15
- member: any;
16
- id: string;
17
- global_name: null;
18
- discriminator: string;
19
- bot: boolean;
20
- avatar_decoration_data: null;
21
- avatar: string;
22
- }[];
23
- mention_roles: any[];
24
- mention_everyone: boolean;
25
- member: {
26
- roles: any[];
27
- premium_since: null;
28
- pending: boolean;
29
- nick: null;
30
- mute: boolean;
31
- joined_at: string;
32
- flags: number;
33
- deaf: boolean;
34
- communication_disabled_until: null;
35
- avatar: null;
36
- };
37
- id: string;
38
- flags: number;
39
- embeds: any[];
40
- edited_timestamp: null;
41
- content: string;
42
- components: any[];
43
- channel_id: string;
44
- author: {
45
- username: string;
46
- public_flags: number;
47
- premium_type: number;
48
- id: string;
49
- global_name: string;
50
- discriminator: string;
51
- avatar_decoration_data: null;
52
- avatar: string;
53
- bot?: boolean;
54
- };
55
- attachments: any[];
56
- guild_id: string;
57
- };
58
-
59
- export type { MESSAGE_CREATE_TYPE };
@@ -1,11 +0,0 @@
1
- /**
2
- * 消息撤回
3
- * @param event
4
- */
5
- type MESSAGE_DELETE_TYPE = {
6
- id: string;
7
- channel_id: string;
8
- guild_id: string;
9
- };
10
-
11
- export type { MESSAGE_DELETE_TYPE };
@@ -1,42 +0,0 @@
1
- /**
2
- * 表情增加
3
- * @param event
4
- */
5
- type MESSAGE_REACTION_ADD_TYPE = {
6
- user_id: string;
7
- type: number;
8
- message_id: string;
9
- message_author_id: string;
10
- member: {
11
- user: {
12
- username: string;
13
- public_flags: number;
14
- id: string;
15
- global_name: string;
16
- display_name: string;
17
- discriminator: string;
18
- bot: boolean;
19
- avatar_decoration_data: null;
20
- avatar: string;
21
- };
22
- roles: string[];
23
- premium_since: null;
24
- pending: boolean;
25
- nick: null;
26
- mute: boolean;
27
- joined_at: string;
28
- flags: number;
29
- deaf: boolean;
30
- communication_disabled_until: null;
31
- avatar: null;
32
- };
33
- emoji: {
34
- name: string;
35
- id: string;
36
- };
37
- channel_id: string;
38
- burst: boolean;
39
- guild_id: string;
40
- };
41
-
42
- export type { MESSAGE_REACTION_ADD_TYPE };
@@ -1,56 +0,0 @@
1
- /**
2
- * 消息更新
3
- * @param event
4
- */
5
- type MESSAGE_UPDATE_TYPE = {
6
- type: number;
7
- tts: boolean;
8
- timestamp: string;
9
- pinned: boolean;
10
- mentions: any[];
11
- mention_roles: string[];
12
- mention_everyone: boolean;
13
- member: {
14
- roles: string[];
15
- premium_since: null;
16
- pending: boolean;
17
- nick: null;
18
- mute: boolean;
19
- joined_at: string;
20
- flags: number;
21
- deaf: boolean;
22
- communication_disabled_until: null;
23
- avatar: null;
24
- };
25
- id: string;
26
- flags: number;
27
- embeds: {
28
- type: string;
29
- title: string;
30
- image: any;
31
- description: '';
32
- color: number;
33
- }[];
34
- edited_timestamp: string;
35
- content: string;
36
- components: {
37
- type: number;
38
- components: any;
39
- }[];
40
- channel_id: string;
41
- author: {
42
- username: string;
43
- public_flags: number;
44
- premium_type: number;
45
- id: string;
46
- global_name: null;
47
- discriminator: string;
48
- bot: true;
49
- avatar_decoration_data: null;
50
- avatar: string;
51
- };
52
- attachments: any[];
53
- guild_id: string;
54
- };
55
-
56
- export type { MESSAGE_UPDATE_TYPE };
@@ -1,63 +0,0 @@
1
- /**
2
- * 表态 更新
3
- * @param event
4
- */
5
- type PRESENCE_UPDATE_TYPE = {
6
- user: {
7
- id: number;
8
- } | {
9
- username: string;
10
- public_flags: number;
11
- id: string;
12
- global_name: string;
13
- discriminator: string;
14
- avatar_decoration_data: {
15
- sku_id: string;
16
- asset: string;
17
- };
18
- avatar: string;
19
- };
20
- status: string;
21
- guild_id: string;
22
- client_status: {
23
- desktop: string;
24
- };
25
- broadcast: null;
26
- activities: {
27
- type: number;
28
- timestamps: any;
29
- state: string;
30
- name: string;
31
- id: string;
32
- details: string;
33
- created_at: number;
34
- assets: any;
35
- application_id: string;
36
- }[] | {
37
- type: number;
38
- state: string;
39
- name: string;
40
- id: string;
41
- emoji: any;
42
- created_at: number;
43
- }[] | {
44
- type: number;
45
- name: string;
46
- id: string;
47
- created_at: number;
48
- }[] | {
49
- type: number;
50
- timestamps: any;
51
- state: string;
52
- session_id: string;
53
- name: string;
54
- id: string;
55
- details: string;
56
- created_at: number;
57
- buttons: any[];
58
- assets: any;
59
- application_id: string;
60
- }[];
61
- };
62
-
63
- export type { PRESENCE_UPDATE_TYPE };
@@ -1,9 +0,0 @@
1
- type READY_TYPE = {
2
- user: {
3
- id: any;
4
- avatar: string;
5
- username: string;
6
- };
7
- };
8
-
9
- export type { READY_TYPE };
@@ -1,35 +0,0 @@
1
- /**
2
- * 类型开始
3
- * @param event
4
- */
5
- type TYPING_START_TYPE = {
6
- user_id: string;
7
- timestamp: number;
8
- member: {
9
- user: {
10
- username: string;
11
- public_flags: number;
12
- id: string;
13
- global_name: string;
14
- display_name: string;
15
- discriminator: string;
16
- bot: boolean;
17
- avatar_decoration_data: null;
18
- avatar: string;
19
- };
20
- roles: string[];
21
- premium_since: string;
22
- pending: boolean;
23
- nick: string;
24
- mute: boolean;
25
- joined_at: string;
26
- flags: number;
27
- deaf: boolean;
28
- communication_disabled_until: null;
29
- avatar: null;
30
- };
31
- channel_id: string;
32
- guild_id: string;
33
- };
34
-
35
- export type { TYPING_START_TYPE };
@@ -1,10 +0,0 @@
1
- /**
2
- * 音频子频道状态更新
3
- */
4
- type VOICE_CHANNEL_STATUS_UPDATE_TYPE = {
5
- status: null;
6
- id: string;
7
- guild_id: string;
8
- };
9
-
10
- export type { VOICE_CHANNEL_STATUS_UPDATE_TYPE };
@@ -1,41 +0,0 @@
1
- /**
2
- * 音频状态更新
3
- */
4
- type VOICE_STATE_UPDATE_TYPE = {
5
- member: {
6
- user: {
7
- username: string;
8
- public_flags: number;
9
- id: string;
10
- global_name: string;
11
- display_name: string;
12
- discriminator: string;
13
- bot: boolean;
14
- avatar_decoration_data: any;
15
- avatar: string;
16
- };
17
- roles: string[];
18
- premium_since: null;
19
- pending: boolean;
20
- nick: null;
21
- mute: boolean;
22
- joined_at: string;
23
- flags: number;
24
- deaf: boolean;
25
- communication_disabled_until: null;
26
- avatar: string;
27
- };
28
- user_id: string;
29
- suppress: boolean;
30
- session_id: string;
31
- self_video: boolean;
32
- self_mute: true;
33
- self_deaf: boolean;
34
- request_to_speak_timestamp: null;
35
- mute: boolean;
36
- guild_id: string;
37
- deaf: boolean;
38
- channel_id: string;
39
- };
40
-
41
- export type { VOICE_STATE_UPDATE_TYPE };
@@ -1,37 +0,0 @@
1
- import { CHANNEL_TOPIC_UPDATE_TYPE } from './message/CHANNEL_TOPIC_UPDATE.js';
2
- import { CHANNEL_UPDATE_TYPE } from './message/CHANNEL_UPDATE.js';
3
- import { GUILD_MEMBER_ADD_TYPE } from './message/GUILD_MEMBER_ADD.js';
4
- import { GUILD_MEMBER_REMOVE_TYPE } from './message/GUILD_MEMBER_REMOVE.js';
5
- import { GUILD_MEMBER_UPDATE_TYPE } from './message/GUILD_MEMBER_UPDATE.js';
6
- import { MESSAGE_CREATE_TYPE } from './message/MESSAGE_CREATE.js';
7
- import { MESSAGE_DELETE_TYPE } from './message/MESSAGE_DELETE.js';
8
- import { MESSAGE_REACTION_ADD_TYPE } from './message/MESSAGE_REACTION_ADD.js';
9
- import { MESSAGE_UPDATE_TYPE } from './message/MESSAGE_UPDATE.js';
10
- import { PRESENCE_UPDATE_TYPE } from './message/PRESENCE_UPDATE.js';
11
- import { READY_TYPE } from './message/READY.js';
12
- import { TYPING_START_TYPE } from './message/TYPING_START.js';
13
- import { VOICE_CHANNEL_STATUS_UPDATE_TYPE } from './message/VOICE_CHANNEL_STATUS_UPDATE.js';
14
- import { VOICE_STATE_UPDATE_TYPE } from './message/VOICE_STATE_UPDATE.js';
15
-
16
- /**
17
- * discord事件map
18
- */
19
- type DCEventMap = {
20
- CHANNEL_TOPIC_UPDATE: CHANNEL_TOPIC_UPDATE_TYPE;
21
- CHANNEL_UPDATE: CHANNEL_UPDATE_TYPE;
22
- GUILD_MEMBER_ADD: GUILD_MEMBER_ADD_TYPE;
23
- GUILD_MEMBER_REMOVE: GUILD_MEMBER_REMOVE_TYPE;
24
- GUILD_MEMBER_UPDATE: GUILD_MEMBER_UPDATE_TYPE;
25
- MESSAGE_CREATE: MESSAGE_CREATE_TYPE;
26
- MESSAGE_DELETE: MESSAGE_DELETE_TYPE;
27
- MESSAGE_REACTION_ADD: MESSAGE_REACTION_ADD_TYPE;
28
- MESSAGE_UPDATE: MESSAGE_UPDATE_TYPE;
29
- PRESENCE_UPDATE: PRESENCE_UPDATE_TYPE;
30
- READY: READY_TYPE;
31
- TYPING_START: TYPING_START_TYPE;
32
- VOICE_CHANNEL_STATUS_UPDATE: VOICE_CHANNEL_STATUS_UPDATE_TYPE;
33
- VOICE_STATE_UPDATE: VOICE_STATE_UPDATE_TYPE;
34
- ERROR: any;
35
- };
36
-
37
- export type { DCEventMap };
@@ -1,4 +0,0 @@
1
- declare const AvailableIntentsEventsEnum: readonly ["GUILDS", "MEMBERS", "GUILD_MODERATION", "GUILD_EMOJIS_AND_STICKERS", "GUILD_INTEGRATIONS", "GUILD_WEBHOOKS", "GUILD_INVITES", "GUILD_VOICE_STATES", "GUILD_PRESENCES", "GUILD_MESSAGES", "REACTIONS", "GUILD_MESSAGE_TYPING", "DIRECT_MESSAGES", "DIRECT_MESSAGE_REACTIONS", "DIRECT_MESSAGE_TYPING", "MESSAGE_CONTENT", "GUILD_SCHEDULED_EVENTS", "AUTO_MODERATION_CONFIGURATION", "AUTO_MODERATION_EXECUTION"];
2
- type DCIntentsEnum = (typeof AvailableIntentsEventsEnum)[number];
3
-
4
- export type { DCIntentsEnum };
@@ -1,27 +0,0 @@
1
- import { DCAPI } from './api.js';
2
- import { DISOCRDOptions } from './wss.types.js';
3
- import { DCEventMap } from './message.js';
4
-
5
- declare class DCClient extends DCAPI {
6
- #private;
7
- /**
8
- * 设置配置
9
- * @param opstion
10
- */
11
- constructor(opstion: DISOCRDOptions);
12
- /**
13
- * 注册事件处理程序
14
- * @param key 事件名称
15
- * @param val 事件处理函数
16
- */
17
- on<T extends keyof DCEventMap>(key: T, val: (event: DCEventMap[T]) => any): this;
18
- /**
19
- * 创建ws监听
20
- * @param conversation
21
- * @param shard
22
- * @returns
23
- */
24
- connect(): Promise<void>;
25
- }
26
-
27
- export { DCClient };
@@ -1,26 +0,0 @@
1
- import { DCIntentsEnum } from './types.js';
2
-
3
- /**
4
- * ****
5
- * discord
6
- * ***
7
- */
8
- interface DISOCRDOptions {
9
- /**
10
- * 钥匙
11
- */
12
- token: string;
13
- /**
14
- * 订阅(有默认值)
15
- * ******
16
- */
17
- intent?: DCIntentsEnum[];
18
- /**
19
- * 分片(有默认值)
20
- * ******
21
- * [0, 1]
22
- */
23
- shard?: number[];
24
- }
25
-
26
- export type { DISOCRDOptions };
File without changes