@alemonjs/discord 0.2.2 → 0.2.3

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.
@@ -0,0 +1,11 @@
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 };
@@ -0,0 +1,48 @@
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 };
@@ -0,0 +1,28 @@
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 };
@@ -0,0 +1,18 @@
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 };
@@ -0,0 +1,33 @@
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 };
@@ -0,0 +1,59 @@
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 };
@@ -0,0 +1,11 @@
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 };
@@ -0,0 +1,42 @@
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 };
@@ -0,0 +1,56 @@
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 };
@@ -0,0 +1,63 @@
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 };
@@ -0,0 +1,9 @@
1
+ type READY_TYPE = {
2
+ user: {
3
+ id: any;
4
+ avatar: string;
5
+ username: string;
6
+ };
7
+ };
8
+
9
+ export type { READY_TYPE };
@@ -0,0 +1,35 @@
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 };
@@ -0,0 +1,10 @@
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 };
@@ -0,0 +1,41 @@
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 };
@@ -0,0 +1,37 @@
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 };
@@ -0,0 +1,4 @@
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 };
@@ -0,0 +1,27 @@
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 };
@@ -0,0 +1,26 @@
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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@alemonjs/discord",
3
- "version": "0.2.2",
4
- "description": "discord-bot",
3
+ "version": "0.2.3",
4
+ "description": "阿柠檬discord平台连接",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
@@ -10,19 +10,34 @@
10
10
  "scripts": {
11
11
  "build": "node bundle.js"
12
12
  },
13
- "devDependencies": {
14
- "@rollup/plugin-typescript": "^11.1.6",
15
- "lvyjs": "^0.2.13",
16
- "rollup": "^4.18.1",
17
- "rollup-plugin-dts": "^6.1.1",
18
- "tsx": "^4.19.1"
19
- },
20
13
  "exports": {
21
14
  ".": {
22
15
  "import": "./lib/index.js",
23
16
  "types": "./lib/index.d.ts"
24
17
  },
25
- "./package": "./package.json"
18
+ "./package": "./package.json",
19
+ "./desktop": "./lib/desktop.js"
20
+ },
21
+ "alemonjs": {
22
+ "desktop": {
23
+ "platform": [
24
+ {
25
+ "name": "discord"
26
+ }
27
+ ],
28
+ "commond": [
29
+ {
30
+ "name": "DC",
31
+ "commond": "open.discord"
32
+ }
33
+ ],
34
+ "sidebars": [
35
+ {
36
+ "name": "DC",
37
+ "commond": "open.discord"
38
+ }
39
+ ]
40
+ }
26
41
  },
27
42
  "keywords": [
28
43
  "alemonjs"