@alemonjs/discord 0.2.1 → 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
@@ -12,7 +12,9 @@ import { DCClient } from './sdk/platform/discord/sdk/wss.js';
12
12
  const client = new Proxy({}, {
13
13
  get: (_, prop) => {
14
14
  if (prop in global.client) {
15
- return global.client[prop];
15
+ const original = global.client[prop];
16
+ // 防止函数内this丢失
17
+ return typeof original === 'function' ? original.bind(global.client) : original;
16
18
  }
17
19
  return undefined;
18
20
  }
@@ -20,9 +22,7 @@ const client = new Proxy({}, {
20
22
  const platform = 'discord';
21
23
  var index = defineBot(() => {
22
24
  const value = getConfigValue();
23
- const config = value?.discord;
24
- if (!config)
25
- return;
25
+ const config = value[platform];
26
26
  // 创建客户端
27
27
  const client = new DCClient({
28
28
  token: config.token
@@ -171,7 +171,6 @@ var index = defineBot(() => {
171
171
  const event = e.value;
172
172
  const MessageMention = event.mentions.map(item => {
173
173
  let url = null;
174
- const Platform = 'discord';
175
174
  const UserId = item.id;
176
175
  const avatar = event.author.avatar;
177
176
  const value = getConfigValue();
@@ -205,7 +204,7 @@ var index = defineBot(() => {
205
204
  IsBot: item.bot,
206
205
  UserAvatar,
207
206
  UserKey: useUserHashKey({
208
- Platform: Platform,
207
+ Platform: platform,
209
208
  UserId: UserId
210
209
  })
211
210
  };
package/package.json CHANGED
@@ -1,23 +1,31 @@
1
1
  {
2
2
  "name": "@alemonjs/discord",
3
- "version": "0.2.1",
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,9 +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 platform = "discord";
7
- declare const _default: () => alemonjs.ClientAPI;
8
-
9
- export { type Client, client, _default as default, platform };