@alemonjs/discord 0.2.0 → 0.2.2

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/lib/index.js CHANGED
@@ -9,17 +9,24 @@ import 'file-type';
9
9
  import 'form-data';
10
10
  import { DCClient } from './sdk/platform/discord/sdk/wss.js';
11
11
 
12
- const client = global.client;
12
+ const client = new Proxy({}, {
13
+ get: (_, prop) => {
14
+ if (prop in global.client) {
15
+ const original = global.client[prop];
16
+ // 防止函数内this丢失
17
+ return typeof original === 'function' ? original.bind(global.client) : original;
18
+ }
19
+ return undefined;
20
+ }
21
+ });
22
+ const platform = 'discord';
13
23
  var index = defineBot(() => {
14
24
  const value = getConfigValue();
15
- const config = value?.discord;
16
- if (!config)
17
- return;
25
+ const config = value[platform];
18
26
  // 创建客户端
19
27
  const client = new DCClient({
20
28
  token: config.token
21
29
  });
22
- const Platform = 'discord';
23
30
  // 连接
24
31
  client.connect();
25
32
  // 监听消息
@@ -44,7 +51,7 @@ var index = defineBot(() => {
44
51
  }
45
52
  const UserId = event.author.id;
46
53
  const UserKey = useUserHashKey({
47
- Platform: Platform,
54
+ Platform: platform,
48
55
  UserId: UserId
49
56
  });
50
57
  let url = null;
@@ -73,7 +80,7 @@ var index = defineBot(() => {
73
80
  // 定义消
74
81
  const e = {
75
82
  // 事件类型
76
- Platform: Platform,
83
+ Platform: platform,
77
84
  // guild
78
85
  GuildId: event.guild_id,
79
86
  ChannelId: event.channel_id,
@@ -164,7 +171,6 @@ var index = defineBot(() => {
164
171
  const event = e.value;
165
172
  const MessageMention = event.mentions.map(item => {
166
173
  let url = null;
167
- const Platform = 'discord';
168
174
  const UserId = item.id;
169
175
  const avatar = event.author.avatar;
170
176
  const value = getConfigValue();
@@ -198,7 +204,7 @@ var index = defineBot(() => {
198
204
  IsBot: item.bot,
199
205
  UserAvatar,
200
206
  UserKey: useUserHashKey({
201
- Platform: Platform,
207
+ Platform: platform,
202
208
  UserId: UserId
203
209
  })
204
210
  };
@@ -210,4 +216,4 @@ var index = defineBot(() => {
210
216
  };
211
217
  });
212
218
 
213
- export { client, index as default };
219
+ export { client, index as default, platform };
package/package.json CHANGED
@@ -1,23 +1,31 @@
1
1
  {
2
2
  "name": "@alemonjs/discord",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "discord-bot",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
9
  "types": "lib",
10
+ "scripts": {
11
+ "build": "node bundle.js"
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
+ },
10
20
  "exports": {
11
21
  ".": {
12
22
  "import": "./lib/index.js",
13
23
  "types": "./lib/index.d.ts"
14
- }
24
+ },
25
+ "./package": "./package.json"
15
26
  },
16
27
  "keywords": [
17
- "alemonjs",
18
- "discord",
19
- "bot",
20
- "chat-bot"
28
+ "alemonjs"
21
29
  ],
22
30
  "publishConfig": {
23
31
  "registry": "https://registry.npmjs.org",
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import * as alemonjs from 'alemonjs';
2
- import { DCClient } from './sdk/platform/discord/sdk/wss.js';
3
-
4
- type Client = typeof DCClient.prototype;
5
- declare const client: Client;
6
- declare const _default: () => alemonjs.ClientAPI;
7
-
8
- export { type Client, client, _default as default };