@alemonjs/discord 0.2.9 → 0.2.10
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/dist/assets/index.css +1248 -1
- package/dist/assets/index.js +10990 -4
- package/dist/index.html +1 -1
- package/lib/env.js +1 -0
- package/lib/index.d.ts +4 -3
- package/lib/index.js +120 -221
- package/lib/sdk/{platform/discord/sdk/api.d.ts → api.d.ts} +54 -2
- package/lib/sdk/{platform/discord/sdk/api.js → api.js} +20 -7
- package/lib/sdk/config.js +10 -0
- package/lib/sdk/intents.js +154 -0
- package/lib/sdk/message/INTERACTION_CREATE.d.ts +126 -0
- package/lib/sdk/message.d.ts +101 -0
- package/lib/sdk/types.d.ts +5 -0
- package/lib/sdk/types.js +25 -0
- package/lib/sdk/{platform/discord/sdk/wss.d.ts → wss.d.ts} +1 -1
- package/lib/sdk/{platform/discord/sdk/wss.js → wss.js} +14 -7
- package/lib/sdk/{platform/discord/sdk/wss.types.d.ts → wss.types.d.ts} +4 -0
- package/lib/send.js +204 -0
- package/package.json +4 -1
- package/lib/sdk/platform/discord/sdk/config.js +0 -29
- package/lib/sdk/platform/discord/sdk/intents.js +0 -36
- package/lib/sdk/platform/discord/sdk/message.d.ts +0 -37
- package/lib/sdk/platform/discord/sdk/types.d.ts +0 -4
- /package/lib/sdk/core/{utils/from.js → from.js} +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/CHANNEL_TOPIC_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/CHANNEL_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/GUILD_MEMBER_ADD.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/GUILD_MEMBER_REMOVE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/GUILD_MEMBER_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/MESSAGE_CREATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/MESSAGE_DELETE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/MESSAGE_REACTION_ADD.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/MESSAGE_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/PRESENCE_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/READY.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/TYPING_START.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/VOICE_CHANNEL_STATUS_UPDATE.d.ts +0 -0
- /package/lib/sdk/{platform/discord/sdk/message → message}/VOICE_STATE_UPDATE.d.ts +0 -0
package/dist/index.html
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>AlemonJS</title>
|
|
8
8
|
<script type="module" crossorigin src="/assets/index.js"></script>
|
|
9
|
-
<link rel="stylesheet" crossorigin href="/assets/index.css"
|
|
9
|
+
<link rel="stylesheet" crossorigin href="/assets/index.css" />
|
|
10
10
|
</head>
|
|
11
11
|
|
|
12
12
|
<body>
|
package/lib/env.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import * as alemonjs from 'alemonjs';
|
|
2
|
-
import { DCClient } from './sdk/
|
|
2
|
+
import { DCClient } from './sdk/wss.js';
|
|
3
3
|
|
|
4
4
|
type Client = typeof DCClient.prototype;
|
|
5
5
|
declare const client: Client;
|
|
6
6
|
declare const platform = "discord";
|
|
7
|
-
declare const _default: alemonjs.
|
|
7
|
+
declare const _default: alemonjs.DefinePlatformValue;
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export { client, _default as default, platform };
|
|
10
|
+
export type { Client };
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
import '
|
|
5
|
-
import '
|
|
6
|
-
import 'public-ip';
|
|
7
|
-
import 'stream';
|
|
8
|
-
import 'file-type';
|
|
9
|
-
import 'form-data';
|
|
10
|
-
import { DCClient } from './sdk/platform/discord/sdk/wss.js';
|
|
1
|
+
import './env.js';
|
|
2
|
+
import { definePlatform, getConfigValue, useUserHashKey, onProcessor } from 'alemonjs';
|
|
3
|
+
import { sendchannel, senduser } from './send.js';
|
|
4
|
+
import { DCClient } from './sdk/wss.js';
|
|
5
|
+
import { AvailableIntentsEventsEnum } from './sdk/types.js';
|
|
11
6
|
|
|
12
7
|
const client = new Proxy({}, {
|
|
13
8
|
get: (_, prop) => {
|
|
@@ -20,17 +15,20 @@ const client = new Proxy({}, {
|
|
|
20
15
|
}
|
|
21
16
|
});
|
|
22
17
|
const platform = 'discord';
|
|
23
|
-
var index =
|
|
18
|
+
var index = definePlatform(() => {
|
|
24
19
|
let value = getConfigValue();
|
|
25
20
|
if (!value)
|
|
26
21
|
value = {};
|
|
27
22
|
const config = value[platform];
|
|
28
23
|
// 创建客户端
|
|
29
24
|
const client = new DCClient({
|
|
30
|
-
|
|
25
|
+
gatewayURL: config?.gatewayURL,
|
|
26
|
+
token: config.token,
|
|
27
|
+
shard: config?.shard ?? [0, 1],
|
|
28
|
+
intent: config?.intent ?? AvailableIntentsEventsEnum
|
|
31
29
|
});
|
|
32
30
|
// 连接
|
|
33
|
-
client.connect();
|
|
31
|
+
client.connect(config?.gatewayURL);
|
|
34
32
|
const ImageURLToBuffer = async (url) => {
|
|
35
33
|
const arrayBuffer = await fetch(url).then(res => res.arrayBuffer());
|
|
36
34
|
return Buffer.from(arrayBuffer);
|
|
@@ -70,9 +68,6 @@ var index = defineBot(() => {
|
|
|
70
68
|
// 消除bot消息
|
|
71
69
|
if (event.author?.bot)
|
|
72
70
|
return;
|
|
73
|
-
console.log('event', event);
|
|
74
|
-
const master_key = config?.master_key ?? [];
|
|
75
|
-
const isMaster = master_key.includes(event.author.id);
|
|
76
71
|
// 艾特消息处理
|
|
77
72
|
const at_users = [];
|
|
78
73
|
// 获取艾特用户
|
|
@@ -91,10 +86,38 @@ var index = defineBot(() => {
|
|
|
91
86
|
Platform: platform,
|
|
92
87
|
UserId: UserId
|
|
93
88
|
});
|
|
89
|
+
const master_key = config?.master_key ?? [];
|
|
90
|
+
const isMaster = master_key.includes(UserKey);
|
|
94
91
|
const UserAvatar = createUserAvatar(UserId, event.author.avatar);
|
|
95
|
-
if (event.type == 0) {
|
|
96
|
-
//
|
|
97
|
-
|
|
92
|
+
if (event.type == 0 && event.member) {
|
|
93
|
+
// 处理消息
|
|
94
|
+
onProcessor('message.create', {
|
|
95
|
+
name: 'message.create',
|
|
96
|
+
// 事件类型
|
|
97
|
+
Platform: platform,
|
|
98
|
+
// guild
|
|
99
|
+
GuildId: event.guild_id,
|
|
100
|
+
ChannelId: event.channel_id,
|
|
101
|
+
// user
|
|
102
|
+
UserId: UserId,
|
|
103
|
+
UserKey,
|
|
104
|
+
UserName: event.author.username,
|
|
105
|
+
UserAvatar: UserAvatar,
|
|
106
|
+
IsMaster: isMaster,
|
|
107
|
+
IsBot: false,
|
|
108
|
+
// message
|
|
109
|
+
MessageId: event.id,
|
|
110
|
+
MessageText: msg,
|
|
111
|
+
OpenId: '',
|
|
112
|
+
CreateAt: Date.now(),
|
|
113
|
+
// other
|
|
114
|
+
tag: 'message.create',
|
|
115
|
+
value: null
|
|
116
|
+
}, event);
|
|
117
|
+
}
|
|
118
|
+
else if (event.type == 0 && !event.member) {
|
|
119
|
+
// 处理消息
|
|
120
|
+
onProcessor('private.message.create', {
|
|
98
121
|
name: 'private.message.create',
|
|
99
122
|
// 事件类型
|
|
100
123
|
Platform: platform,
|
|
@@ -116,41 +139,78 @@ var index = defineBot(() => {
|
|
|
116
139
|
// other
|
|
117
140
|
tag: 'private.message.create',
|
|
118
141
|
value: null
|
|
119
|
-
};
|
|
142
|
+
}, event);
|
|
143
|
+
}
|
|
144
|
+
else ;
|
|
145
|
+
});
|
|
146
|
+
client.on('INTERACTION_CREATE', event => {
|
|
147
|
+
console.log('event', event);
|
|
148
|
+
const isPrivate = typeof event['user'] === 'object' ? true : false;
|
|
149
|
+
const user = isPrivate ? event['user'] : event['member'].user;
|
|
150
|
+
const UserId = user.id;
|
|
151
|
+
const UserKey = useUserHashKey({
|
|
152
|
+
Platform: platform,
|
|
153
|
+
UserId: UserId
|
|
154
|
+
});
|
|
155
|
+
const UserAvatar = createUserAvatar(UserId, user.avatar);
|
|
156
|
+
const UserName = user.username;
|
|
157
|
+
const master_key = config?.master_key ?? [];
|
|
158
|
+
const isMaster = master_key.includes(UserKey);
|
|
159
|
+
const MessageText = event.data.custom_id;
|
|
160
|
+
if (isPrivate) {
|
|
120
161
|
// 处理消息
|
|
121
|
-
onProcessor('private.
|
|
162
|
+
onProcessor('private.interaction.create', {
|
|
163
|
+
name: 'private.interaction.create',
|
|
164
|
+
// 事件类型
|
|
165
|
+
Platform: platform,
|
|
166
|
+
// guild
|
|
167
|
+
// GuildId: event['guild_id'],
|
|
168
|
+
// ChannelId: event.channel_id,
|
|
169
|
+
// user
|
|
170
|
+
UserId: UserId,
|
|
171
|
+
UserKey,
|
|
172
|
+
UserName: UserName,
|
|
173
|
+
UserAvatar: UserAvatar,
|
|
174
|
+
IsMaster: isMaster,
|
|
175
|
+
IsBot: false,
|
|
176
|
+
// message
|
|
177
|
+
MessageId: event.id,
|
|
178
|
+
MessageText: MessageText,
|
|
179
|
+
OpenId: '',
|
|
180
|
+
CreateAt: Date.now(),
|
|
181
|
+
// other
|
|
182
|
+
tag: 'private.interaction.create',
|
|
183
|
+
value: null
|
|
184
|
+
}, event);
|
|
122
185
|
}
|
|
123
|
-
else
|
|
124
|
-
//
|
|
125
|
-
|
|
126
|
-
name: '
|
|
186
|
+
else {
|
|
187
|
+
// 处理消息
|
|
188
|
+
onProcessor('interaction.create', {
|
|
189
|
+
name: 'interaction.create',
|
|
127
190
|
// 事件类型
|
|
128
191
|
Platform: platform,
|
|
129
192
|
// guild
|
|
130
|
-
GuildId: event
|
|
193
|
+
GuildId: event['guild_id'],
|
|
131
194
|
ChannelId: event.channel_id,
|
|
132
195
|
// user
|
|
133
196
|
UserId: UserId,
|
|
134
197
|
UserKey,
|
|
135
|
-
UserName:
|
|
198
|
+
UserName: UserName,
|
|
136
199
|
UserAvatar: UserAvatar,
|
|
137
200
|
IsMaster: isMaster,
|
|
138
201
|
IsBot: false,
|
|
139
202
|
// message
|
|
140
203
|
MessageId: event.id,
|
|
141
|
-
MessageText:
|
|
204
|
+
MessageText: MessageText,
|
|
142
205
|
OpenId: '',
|
|
143
206
|
CreateAt: Date.now(),
|
|
144
207
|
// other
|
|
145
|
-
tag: '
|
|
208
|
+
tag: 'interaction.create',
|
|
146
209
|
value: null
|
|
147
|
-
};
|
|
148
|
-
// 处理消息
|
|
149
|
-
onProcessor('message.create', e, event);
|
|
210
|
+
}, event);
|
|
150
211
|
}
|
|
151
|
-
|
|
212
|
+
client.interactionsCallback(event.id, event.token, MessageText);
|
|
152
213
|
});
|
|
153
|
-
// client.on('')
|
|
154
214
|
// 发送错误时
|
|
155
215
|
client.on('ERROR', console.error);
|
|
156
216
|
global.client = client;
|
|
@@ -160,203 +220,42 @@ var index = defineBot(() => {
|
|
|
160
220
|
active: {
|
|
161
221
|
send: {
|
|
162
222
|
channel: (channel_id, val) => {
|
|
163
|
-
|
|
164
|
-
return Promise.all([]);
|
|
165
|
-
const content = val
|
|
166
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
167
|
-
.map(item => {
|
|
168
|
-
// if (item.type == 'Link') {
|
|
169
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
170
|
-
// } else
|
|
171
|
-
if (item.type == 'Mention') {
|
|
172
|
-
if (item.value == 'everyone' ||
|
|
173
|
-
item.value == 'all' ||
|
|
174
|
-
item.value == '' ||
|
|
175
|
-
typeof item.value != 'string') {
|
|
176
|
-
return `<@everyone>`;
|
|
177
|
-
}
|
|
178
|
-
if (item.options?.belong == 'user') {
|
|
179
|
-
return `<@${item.value}>`;
|
|
180
|
-
}
|
|
181
|
-
else if (item.options?.belong == 'channel') {
|
|
182
|
-
return `<#${item.value}>`;
|
|
183
|
-
}
|
|
184
|
-
return '';
|
|
185
|
-
}
|
|
186
|
-
else if (item.type == 'Text') {
|
|
187
|
-
if (item.options?.style == 'block') {
|
|
188
|
-
return `\`${item.value}\``;
|
|
189
|
-
}
|
|
190
|
-
else if (item.options?.style == 'italic') {
|
|
191
|
-
return `*${item.value}*`;
|
|
192
|
-
}
|
|
193
|
-
else if (item.options?.style == 'bold') {
|
|
194
|
-
return `**${item.value}**`;
|
|
195
|
-
}
|
|
196
|
-
else if (item.options?.style == 'strikethrough') {
|
|
197
|
-
return `~~${item.value}~~`;
|
|
198
|
-
}
|
|
199
|
-
return item.value;
|
|
200
|
-
}
|
|
201
|
-
})
|
|
202
|
-
.join('');
|
|
203
|
-
if (content) {
|
|
204
|
-
return Promise.all([content].map(item => client.channelsMessages(channel_id, {
|
|
205
|
-
content: item
|
|
206
|
-
})));
|
|
207
|
-
}
|
|
208
|
-
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageURL' || item.type == 'ImageFile');
|
|
209
|
-
if (images.length > 0) {
|
|
210
|
-
return Promise.all(images.map(async (item) => {
|
|
211
|
-
if (item.type == 'Image') {
|
|
212
|
-
return client.channelsMessagesImage(channel_id, item.value);
|
|
213
|
-
}
|
|
214
|
-
else if (item.type == 'ImageURL') {
|
|
215
|
-
return client.channelsMessagesImage(channel_id, ImageURLToBuffer(item.value));
|
|
216
|
-
}
|
|
217
|
-
else if (item.type == 'ImageFile') {
|
|
218
|
-
const data = readFileSync(item.value);
|
|
219
|
-
return client.channelsMessagesImage(channel_id, data);
|
|
220
|
-
}
|
|
221
|
-
}));
|
|
222
|
-
}
|
|
223
|
-
return Promise.all([]);
|
|
223
|
+
return sendchannel(client, { channel_id }, val);
|
|
224
224
|
},
|
|
225
225
|
user: async (author_id, val) => {
|
|
226
|
-
|
|
227
|
-
return Promise.all([]);
|
|
228
|
-
const res = await client.userMeChannels(author_id);
|
|
229
|
-
const channel_id = res.id;
|
|
230
|
-
const content = val
|
|
231
|
-
.filter(item => item.type == 'Mention' || item.type == 'Text')
|
|
232
|
-
.map(item => {
|
|
233
|
-
// if (item.type == 'Link') {
|
|
234
|
-
// return `[${item.options?.title ?? item.value}](${item.value})`
|
|
235
|
-
// } else
|
|
236
|
-
if (item.type == 'Mention') {
|
|
237
|
-
if (item.value == 'everyone' ||
|
|
238
|
-
item.value == 'all' ||
|
|
239
|
-
item.value == '' ||
|
|
240
|
-
typeof item.value != 'string') {
|
|
241
|
-
return `<@everyone>`;
|
|
242
|
-
}
|
|
243
|
-
if (item.options?.belong == 'user') {
|
|
244
|
-
return `<@${item.value}>`;
|
|
245
|
-
}
|
|
246
|
-
else if (item.options?.belong == 'channel') {
|
|
247
|
-
return `<#${item.value}>`;
|
|
248
|
-
}
|
|
249
|
-
return '';
|
|
250
|
-
}
|
|
251
|
-
else if (item.type == 'Text') {
|
|
252
|
-
if (item.options?.style == 'block') {
|
|
253
|
-
return `\`${item.value}\``;
|
|
254
|
-
}
|
|
255
|
-
else if (item.options?.style == 'italic') {
|
|
256
|
-
return `*${item.value}*`;
|
|
257
|
-
}
|
|
258
|
-
else if (item.options?.style == 'bold') {
|
|
259
|
-
return `**${item.value}**`;
|
|
260
|
-
}
|
|
261
|
-
else if (item.options?.style == 'strikethrough') {
|
|
262
|
-
return `~~${item.value}~~`;
|
|
263
|
-
}
|
|
264
|
-
return item.value;
|
|
265
|
-
}
|
|
266
|
-
})
|
|
267
|
-
.join('');
|
|
268
|
-
if (content) {
|
|
269
|
-
return Promise.all([content].map(item => client.channelsMessages(channel_id, {
|
|
270
|
-
content: item
|
|
271
|
-
})));
|
|
272
|
-
}
|
|
273
|
-
const images = val.filter(item => item.type == 'Image' || item.type == 'ImageURL' || item.type == 'ImageFile');
|
|
274
|
-
if (images.length > 0) {
|
|
275
|
-
return Promise.all(images.map(async (item) => {
|
|
276
|
-
if (item.type == 'Image') {
|
|
277
|
-
return client.channelsMessagesImage(channel_id, item.value);
|
|
278
|
-
}
|
|
279
|
-
else if (item.type == 'ImageURL') {
|
|
280
|
-
return client.channelsMessagesImage(channel_id, ImageURLToBuffer(item.value));
|
|
281
|
-
}
|
|
282
|
-
else if (item.type == 'ImageFile') {
|
|
283
|
-
const data = readFileSync(item.value);
|
|
284
|
-
return client.channelsMessagesImage(channel_id, data);
|
|
285
|
-
}
|
|
286
|
-
}));
|
|
287
|
-
}
|
|
288
|
-
return Promise.all([]);
|
|
226
|
+
return senduser(client, { author_id: author_id }, val);
|
|
289
227
|
}
|
|
290
228
|
}
|
|
291
229
|
},
|
|
292
230
|
use: {
|
|
293
231
|
send: async (event, val) => {
|
|
294
|
-
if (val.length < 0)
|
|
232
|
+
if (val.length < 0) {
|
|
295
233
|
return Promise.all([]);
|
|
296
|
-
let channel_id = event.ChannelId;
|
|
297
|
-
if (/private/.test(event.name)) {
|
|
298
|
-
const data = event.value;
|
|
299
|
-
channel_id = data?.channel_id;
|
|
300
|
-
if (!channel_id)
|
|
301
|
-
return Promise.all([]);
|
|
302
234
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
else if (item.options?.belong == 'channel') {
|
|
320
|
-
return `<#${item.value}>`;
|
|
321
|
-
}
|
|
322
|
-
return '';
|
|
323
|
-
}
|
|
324
|
-
else if (item.type == 'Text') {
|
|
325
|
-
if (item.options?.style == 'block') {
|
|
326
|
-
return `\`${item.value}\``;
|
|
327
|
-
}
|
|
328
|
-
else if (item.options?.style == 'italic') {
|
|
329
|
-
return `*${item.value}*`;
|
|
330
|
-
}
|
|
331
|
-
else if (item.options?.style == 'bold') {
|
|
332
|
-
return `**${item.value}**`;
|
|
333
|
-
}
|
|
334
|
-
else if (item.options?.style == 'strikethrough') {
|
|
335
|
-
return `~~${item.value}~~`;
|
|
336
|
-
}
|
|
337
|
-
return item.value;
|
|
338
|
-
}
|
|
339
|
-
})
|
|
340
|
-
.join('');
|
|
341
|
-
if (content) {
|
|
342
|
-
return Promise.all([content].map(item => client.channelsMessages(channel_id, {
|
|
343
|
-
content: item
|
|
344
|
-
})));
|
|
235
|
+
const tag = event.tag;
|
|
236
|
+
if (tag == 'message.create') {
|
|
237
|
+
const ChannelId = event.value.channel_id;
|
|
238
|
+
return sendchannel(client, { channel_id: ChannelId }, val);
|
|
239
|
+
}
|
|
240
|
+
else if (tag == 'private.message.create') {
|
|
241
|
+
const UserId = event.value.author.id;
|
|
242
|
+
const ChannelId = event.value.channel_id;
|
|
243
|
+
return senduser(client, {
|
|
244
|
+
channel_id: ChannelId,
|
|
245
|
+
author_id: UserId
|
|
246
|
+
}, val);
|
|
247
|
+
}
|
|
248
|
+
else if (tag == 'interaction.create') {
|
|
249
|
+
const ChannelId = event.value.channel_id;
|
|
250
|
+
return sendchannel(client, { channel_id: ChannelId }, val);
|
|
345
251
|
}
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
return client.channelsMessagesImage(channel_id, ImageURLToBuffer(item.value));
|
|
354
|
-
}
|
|
355
|
-
else if (item.type == 'ImageFile') {
|
|
356
|
-
const data = readFileSync(item.value);
|
|
357
|
-
return client.channelsMessagesImage(channel_id, data);
|
|
358
|
-
}
|
|
359
|
-
}));
|
|
252
|
+
else if (tag == 'private.interaction.create') {
|
|
253
|
+
const UserId = event.value.user.id;
|
|
254
|
+
const ChannelId = event.value.channel_id;
|
|
255
|
+
return senduser(client, {
|
|
256
|
+
channel_id: ChannelId,
|
|
257
|
+
author_id: UserId
|
|
258
|
+
}, val);
|
|
360
259
|
}
|
|
361
260
|
return Promise.all([]);
|
|
362
261
|
},
|
|
@@ -36,8 +36,9 @@ declare class DCAPI {
|
|
|
36
36
|
getUserUrl(user_id: string, avatar_hash: string): Promise<any>;
|
|
37
37
|
/**
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
39
|
+
* @param channel_id
|
|
40
|
+
* @param data
|
|
41
|
+
* @param headers
|
|
41
42
|
* @returns
|
|
42
43
|
*/
|
|
43
44
|
channelsMessages(channel_id: string, data: {
|
|
@@ -47,6 +48,53 @@ declare class DCAPI {
|
|
|
47
48
|
title?: string;
|
|
48
49
|
description?: string;
|
|
49
50
|
}[];
|
|
51
|
+
components?: {
|
|
52
|
+
type: number;
|
|
53
|
+
components: {
|
|
54
|
+
type: number;
|
|
55
|
+
style: number;
|
|
56
|
+
label?: string;
|
|
57
|
+
emoji?: any;
|
|
58
|
+
custom_id?: string;
|
|
59
|
+
sku_id?: any;
|
|
60
|
+
url?: string;
|
|
61
|
+
disabled?: boolean;
|
|
62
|
+
}[] | {
|
|
63
|
+
type: number;
|
|
64
|
+
custom_id?: string;
|
|
65
|
+
options?: {
|
|
66
|
+
label: string;
|
|
67
|
+
value: string;
|
|
68
|
+
description?: string;
|
|
69
|
+
emoji?: {
|
|
70
|
+
name?: string;
|
|
71
|
+
id?: string;
|
|
72
|
+
};
|
|
73
|
+
}[];
|
|
74
|
+
}[] | {
|
|
75
|
+
custom_id: string;
|
|
76
|
+
max_values: number;
|
|
77
|
+
min_values: number;
|
|
78
|
+
options: {
|
|
79
|
+
description?: string;
|
|
80
|
+
emoji?: {
|
|
81
|
+
name?: string;
|
|
82
|
+
id?: string;
|
|
83
|
+
};
|
|
84
|
+
label: string;
|
|
85
|
+
value: string;
|
|
86
|
+
}[];
|
|
87
|
+
}[] | {
|
|
88
|
+
type: number;
|
|
89
|
+
custom_id: string;
|
|
90
|
+
label: string;
|
|
91
|
+
style: number;
|
|
92
|
+
min_length: number;
|
|
93
|
+
max_length: number;
|
|
94
|
+
placeholder: string;
|
|
95
|
+
required: boolean;
|
|
96
|
+
}[];
|
|
97
|
+
}[];
|
|
50
98
|
files?: any[];
|
|
51
99
|
}, headers?: AxiosRequestConfig['headers']): Promise<any>;
|
|
52
100
|
/**
|
|
@@ -891,6 +939,10 @@ declare class DCAPI {
|
|
|
891
939
|
gateway(): Promise<{
|
|
892
940
|
url: string;
|
|
893
941
|
}>;
|
|
942
|
+
/**
|
|
943
|
+
*
|
|
944
|
+
*/
|
|
945
|
+
interactionsCallback(id: string, token: string, content: string): Promise<any>;
|
|
894
946
|
}
|
|
895
947
|
|
|
896
948
|
export { DCAPI };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import FormData from 'form-data';
|
|
2
|
-
import 'fs';
|
|
3
2
|
import axios from 'axios';
|
|
4
|
-
import 'path';
|
|
5
|
-
import 'qrcode';
|
|
6
|
-
import 'public-ip';
|
|
7
|
-
import { createPicFrom } from '../../../core/utils/from.js';
|
|
8
3
|
import { config } from './config.js';
|
|
4
|
+
import { createPicFrom } from './core/from.js';
|
|
9
5
|
|
|
10
6
|
/**
|
|
11
7
|
* api接口
|
|
@@ -71,8 +67,9 @@ class DCAPI {
|
|
|
71
67
|
}
|
|
72
68
|
/**
|
|
73
69
|
*
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
70
|
+
* @param channel_id
|
|
71
|
+
* @param data
|
|
72
|
+
* @param headers
|
|
76
73
|
* @returns
|
|
77
74
|
*/
|
|
78
75
|
async channelsMessages(channel_id, data, headers) {
|
|
@@ -1552,6 +1549,22 @@ class DCAPI {
|
|
|
1552
1549
|
url: '/gateway'
|
|
1553
1550
|
}).then(res => res?.data);
|
|
1554
1551
|
}
|
|
1552
|
+
/**
|
|
1553
|
+
*
|
|
1554
|
+
*/
|
|
1555
|
+
async interactionsCallback(id, token, content) {
|
|
1556
|
+
return this.request({
|
|
1557
|
+
method: 'POST',
|
|
1558
|
+
url: `/interactions/${id}/${token}/callback`,
|
|
1559
|
+
data: {
|
|
1560
|
+
type: 4, // CHANNEL_MESSAGE_WITH_SOURCE
|
|
1561
|
+
data: {
|
|
1562
|
+
content: content,
|
|
1563
|
+
flags: 64 // EPHEMERAL(仅发送者可见)
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
}).then(res => res.data);
|
|
1567
|
+
}
|
|
1555
1568
|
}
|
|
1556
1569
|
|
|
1557
1570
|
export { DCAPI };
|