@alemonjs/discord 2.1.0-alpha.0 → 2.1.0-alpha.1
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 +1 -26
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -25,10 +25,6 @@ var index = () => {
|
|
|
25
25
|
const cbp = cbpPlatform(url);
|
|
26
26
|
// 连接
|
|
27
27
|
client.connect(config?.gatewayURL);
|
|
28
|
-
const ImageURLToBuffer = async (url) => {
|
|
29
|
-
const arrayBuffer = await fetch(url).then(res => res.arrayBuffer());
|
|
30
|
-
return Buffer.from(arrayBuffer);
|
|
31
|
-
};
|
|
32
28
|
/**
|
|
33
29
|
* 创建用户头像
|
|
34
30
|
* @param UserId
|
|
@@ -36,28 +32,7 @@ var index = () => {
|
|
|
36
32
|
* @returns
|
|
37
33
|
*/
|
|
38
34
|
const createUserAvatar = (UserId, avatar) => {
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
toBuffer: async () => {
|
|
42
|
-
if (!url) {
|
|
43
|
-
url = client.userAvatar(UserId, avatar);
|
|
44
|
-
}
|
|
45
|
-
return ImageURLToBuffer(url);
|
|
46
|
-
},
|
|
47
|
-
toBase64: async () => {
|
|
48
|
-
if (!url) {
|
|
49
|
-
url = client.userAvatar(UserId, avatar);
|
|
50
|
-
}
|
|
51
|
-
const buffer = await ImageURLToBuffer(url);
|
|
52
|
-
return buffer?.toString('base64');
|
|
53
|
-
},
|
|
54
|
-
toURL: async () => {
|
|
55
|
-
if (!url) {
|
|
56
|
-
url = client.userAvatar(UserId, avatar);
|
|
57
|
-
}
|
|
58
|
-
return url;
|
|
59
|
-
}
|
|
60
|
-
};
|
|
35
|
+
return client.userAvatar(UserId, avatar);
|
|
61
36
|
};
|
|
62
37
|
// 监听消息
|
|
63
38
|
client.on('MESSAGE_CREATE', async (event) => {
|