@alemonjs/discord 0.0.1 → 0.0.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.
package/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # [https://lemonade-lab.github.io/alemonjs.com/](https://lemonade-lab.github.io/alemonjs.com/)
2
+
3
+ 跨平台开发的事件驱动机器人
4
+
5
+ ## USE
6
+
7
+ - discord
8
+
9
+ ```sh
10
+ yarn add @alemonjs/discord
11
+ ```
12
+
13
+ - alemon.config.yaml
14
+
15
+ ```sh
16
+ discord:
17
+ # 令牌
18
+ token: ''
19
+ ```
20
+
21
+ > 完整的
22
+
23
+ ```sh
24
+ discord:
25
+ # 令牌
26
+ token: ''
27
+ # 前缀
28
+ intent: []
29
+ # 主人
30
+ master_id: []
31
+ # 活动
32
+ shard: null
33
+ ```
34
+
35
+ ## Community
36
+
37
+ QQ Group 806943302
package/lib/index.d.ts CHANGED
@@ -1,9 +1,5 @@
1
- import { ConfigType } from 'alemonjs'
1
+ import * as alemonjs from 'alemonjs'
2
2
 
3
- /**
4
- *
5
- * @param val
6
- */
7
- declare const login: (config: ConfigType) => void
3
+ declare const _default: (_: alemonjs.ConfigType, __: any) => typeof global.alemonjs
8
4
 
9
- export { login }
5
+ export { _default as default }
package/lib/index.js CHANGED
@@ -1,11 +1,7 @@
1
- import { Text, At, OnProcessor, useParse } from 'alemonjs'
1
+ import { defineBot, Text, At, OnProcessor, useParse } from 'alemonjs'
2
2
  import { DCClient } from 'chat-space'
3
3
 
4
- /**
5
- *
6
- * @param val
7
- */
8
- const login = config => {
4
+ var index = defineBot(config => {
9
5
  // 创建客户端
10
6
  const client = new DCClient({
11
7
  token: config.token
@@ -37,7 +33,7 @@ const login = config => {
37
33
  // 定义消
38
34
  const e = {
39
35
  // 事件类型
40
- Platform: 'kook',
36
+ Platform: 'discord',
41
37
  // 频道
42
38
  GuildId: event.guild_id,
43
39
  // 子频道
@@ -83,37 +79,32 @@ const login = config => {
83
79
  client.on('ERROR', msg => {
84
80
  console.error(msg)
85
81
  })
86
- /**
87
- * 开始实现全局接口
88
- */
89
- if (!global?.alemonjs) {
90
- global.alemonjs = {
91
- api: {
92
- use: {
93
- send: (event, val) => {
94
- if (val.length < 0) return
95
- const content = useParse(val, 'Text')
96
- if (content) {
97
- return Promise.all(
98
- [content].map(item =>
99
- client.channelsMessages(event.ChannelId, {
100
- content: item
101
- })
102
- )
82
+ return {
83
+ api: {
84
+ use: {
85
+ send: (event, val) => {
86
+ if (val.length < 0) return Promise.all([])
87
+ const content = useParse(val, 'Text')
88
+ if (content) {
89
+ return Promise.all(
90
+ [content].map(item =>
91
+ client.channelsMessages(event.ChannelId, {
92
+ content: item
93
+ })
103
94
  )
104
- }
105
- const images = useParse(val, 'Image')
106
- if (images) {
107
- return Promise.all(
108
- images.map(item => client.channelsMessagesImage(event.ChannelId, item))
109
- )
110
- }
111
- return Promise.resolve()
95
+ )
96
+ }
97
+ const images = useParse(val, 'Image')
98
+ if (images) {
99
+ return Promise.all(
100
+ images.map(item => client.channelsMessagesImage(event.ChannelId, item))
101
+ )
112
102
  }
103
+ return Promise.all([])
113
104
  }
114
105
  }
115
106
  }
116
107
  }
117
- }
108
+ })
118
109
 
119
- export { login }
110
+ export { index as default }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@alemonjs/discord",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "啊柠檬脚本",
5
5
  "author": "ningmengchongshui",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
9
  "dependencies": {
10
- "chat-space": "^0.0.3"
10
+ "chat-space": "^0.0.4"
11
11
  },
12
12
  "types": "lib",
13
13
  "exports": {
@@ -19,5 +19,8 @@
19
19
  "publishConfig": {
20
20
  "access": "public",
21
21
  "registry": "https://registry.npmjs.org"
22
- }
22
+ },
23
+ "keywords": [
24
+ "alemonjs"
25
+ ]
23
26
  }