@alemonjs/discord 2.1.12 → 2.1.14
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 +1 -1
- package/dist/assets/index.js +3 -3
- package/dist/index.html +1 -1
- package/lib/index.js +6 -3
- package/lib/sdk/api.d.ts +24 -0
- package/lib/sdk/api.js +145 -0
- package/lib/sdk/message/INTERACTION_CREATE.d.ts +4 -2
- package/package.json +3 -3
- package/LICENSE +0 -21
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>
|
|
7
|
+
<title>ALemonJS</title>
|
|
8
8
|
<script type="module" crossorigin src="/assets/index.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/index.css">
|
|
10
10
|
</head>
|
package/lib/index.js
CHANGED
|
@@ -66,7 +66,8 @@ const main = () => {
|
|
|
66
66
|
const UserAvatar = createUserAvatar(UserId, user.avatar);
|
|
67
67
|
const UserName = user.username;
|
|
68
68
|
const [isMaster, UserKey] = getMaster(UserId);
|
|
69
|
-
const
|
|
69
|
+
const isCustom = !!event.data?.custom_id;
|
|
70
|
+
const MessageText = isCustom ? event?.data?.custom_id : `/${event.data?.name}`;
|
|
70
71
|
if (isPrivate) {
|
|
71
72
|
cbp.send(FormatEvent.create('private.interaction.create')
|
|
72
73
|
.addPlatform({ Platform: platform, value: event, BotId: botId })
|
|
@@ -87,7 +88,7 @@ const main = () => {
|
|
|
87
88
|
.addOpen({ OpenId: UserId })
|
|
88
89
|
.add({ tag: 'interaction.create' }).value);
|
|
89
90
|
}
|
|
90
|
-
void client.interactionsCallback(event.id, event.token,
|
|
91
|
+
void client.interactionsCallback(event.id, event.token, '正在处理您的请求...');
|
|
91
92
|
});
|
|
92
93
|
client.on('MESSAGE_UPDATE', event => {
|
|
93
94
|
if (!event.author) {
|
|
@@ -566,19 +567,21 @@ const main = () => {
|
|
|
566
567
|
const params = data.payload?.params;
|
|
567
568
|
try {
|
|
568
569
|
const keys = key.split('.');
|
|
570
|
+
let parent = null;
|
|
569
571
|
let target = client;
|
|
570
572
|
for (const k of keys) {
|
|
571
573
|
if (target === null || target === undefined || !(k in target)) {
|
|
572
574
|
consume([createResult(ResultCode.Fail, '未知请求,请尝试升级版本', null)]);
|
|
573
575
|
return;
|
|
574
576
|
}
|
|
577
|
+
parent = target;
|
|
575
578
|
target = target[k];
|
|
576
579
|
}
|
|
577
580
|
if (typeof target !== 'function') {
|
|
578
581
|
consume([createResult(ResultCode.Fail, '目标不是可调用方法', null)]);
|
|
579
582
|
return;
|
|
580
583
|
}
|
|
581
|
-
const res = await target(...params);
|
|
584
|
+
const res = await target.call(parent, ...params);
|
|
582
585
|
consume([createResult(ResultCode.Ok, '请求完成', res)]);
|
|
583
586
|
}
|
|
584
587
|
catch (error) {
|
package/lib/sdk/api.d.ts
CHANGED
|
@@ -145,4 +145,28 @@ export declare class DCAPI {
|
|
|
145
145
|
url: string;
|
|
146
146
|
}>;
|
|
147
147
|
interactionsCallback(id: string, token: string, content: string): Promise<any>;
|
|
148
|
+
interactionsCallbackMessage(id: string, token: string, messageData: any): Promise<any>;
|
|
149
|
+
interactionsCallbackForm(id: string, token: string, formData: any): Promise<any>;
|
|
150
|
+
interactionsDeferred(id: string, token: string): Promise<any>;
|
|
151
|
+
interactionsFollowup(application_id: string, token: string, messageData: any): Promise<any>;
|
|
152
|
+
interactionsFollowupForm(application_id: string, token: string, formData: any): Promise<any>;
|
|
153
|
+
getGlobalApplicationCommands(application_id: string, params?: {
|
|
154
|
+
with_localizations?: boolean;
|
|
155
|
+
}): Promise<any>;
|
|
156
|
+
createGlobalApplicationCommand(application_id: string, data: any): Promise<any>;
|
|
157
|
+
getGlobalApplicationCommand(application_id: string, command_id: string): Promise<any>;
|
|
158
|
+
editGlobalApplicationCommand(application_id: string, command_id: string, data: any): Promise<any>;
|
|
159
|
+
deleteGlobalApplicationCommand(application_id: string, command_id: string): Promise<any>;
|
|
160
|
+
bulkOverwriteGlobalApplicationCommands(application_id: string, data: any[]): Promise<any>;
|
|
161
|
+
getGuildApplicationCommands(application_id: string, guild_id: string, params?: {
|
|
162
|
+
with_localizations?: boolean;
|
|
163
|
+
}): Promise<any>;
|
|
164
|
+
createGuildApplicationCommand(application_id: string, guild_id: string, data: any): Promise<any>;
|
|
165
|
+
getGuildApplicationCommand(application_id: string, guild_id: string, command_id: string): Promise<any>;
|
|
166
|
+
editGuildApplicationCommand(application_id: string, guild_id: string, command_id: string, data: any): Promise<any>;
|
|
167
|
+
deleteGuildApplicationCommand(application_id: string, guild_id: string, command_id: string): Promise<any>;
|
|
168
|
+
bulkOverwriteGuildApplicationCommands(application_id: string, guild_id: string, data: any[]): Promise<any>;
|
|
169
|
+
getGuildApplicationCommandPermissions(application_id: string, guild_id: string): Promise<any>;
|
|
170
|
+
getApplicationCommandPermissions(application_id: string, guild_id: string, command_id: string): Promise<any>;
|
|
171
|
+
editApplicationCommandPermissions(application_id: string, guild_id: string, command_id: string, data: any): Promise<any>;
|
|
148
172
|
}
|
package/lib/sdk/api.js
CHANGED
|
@@ -839,6 +839,151 @@ class DCAPI {
|
|
|
839
839
|
}
|
|
840
840
|
});
|
|
841
841
|
}
|
|
842
|
+
interactionsCallbackMessage(id, token, messageData) {
|
|
843
|
+
return this.request({
|
|
844
|
+
method: 'POST',
|
|
845
|
+
url: `/interactions/${id}/${token}/callback`,
|
|
846
|
+
data: {
|
|
847
|
+
type: 4,
|
|
848
|
+
data: messageData
|
|
849
|
+
}
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
interactionsCallbackForm(id, token, formData) {
|
|
853
|
+
return this.request({
|
|
854
|
+
method: 'POST',
|
|
855
|
+
url: `/interactions/${id}/${token}/callback`,
|
|
856
|
+
data: formData,
|
|
857
|
+
headers: {
|
|
858
|
+
'Content-Type': 'multipart/form-data'
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
interactionsDeferred(id, token) {
|
|
863
|
+
return this.request({
|
|
864
|
+
method: 'POST',
|
|
865
|
+
url: `/interactions/${id}/${token}/callback`,
|
|
866
|
+
data: {
|
|
867
|
+
type: 5
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
interactionsFollowup(application_id, token, messageData) {
|
|
872
|
+
return this.request({
|
|
873
|
+
method: 'POST',
|
|
874
|
+
url: `/webhooks/${application_id}/${token}`,
|
|
875
|
+
data: messageData
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
interactionsFollowupForm(application_id, token, formData) {
|
|
879
|
+
return this.request({
|
|
880
|
+
method: 'POST',
|
|
881
|
+
url: `/webhooks/${application_id}/${token}`,
|
|
882
|
+
data: formData,
|
|
883
|
+
headers: {
|
|
884
|
+
'Content-Type': 'multipart/form-data'
|
|
885
|
+
}
|
|
886
|
+
});
|
|
887
|
+
}
|
|
888
|
+
getGlobalApplicationCommands(application_id, params) {
|
|
889
|
+
return this.request({
|
|
890
|
+
method: 'GET',
|
|
891
|
+
url: `/applications/${application_id}/commands`,
|
|
892
|
+
params
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
createGlobalApplicationCommand(application_id, data) {
|
|
896
|
+
return this.request({
|
|
897
|
+
method: 'POST',
|
|
898
|
+
url: `/applications/${application_id}/commands`,
|
|
899
|
+
data
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
getGlobalApplicationCommand(application_id, command_id) {
|
|
903
|
+
return this.request({
|
|
904
|
+
method: 'GET',
|
|
905
|
+
url: `/applications/${application_id}/commands/${command_id}`
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
editGlobalApplicationCommand(application_id, command_id, data) {
|
|
909
|
+
return this.request({
|
|
910
|
+
method: 'PATCH',
|
|
911
|
+
url: `/applications/${application_id}/commands/${command_id}`,
|
|
912
|
+
data
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
deleteGlobalApplicationCommand(application_id, command_id) {
|
|
916
|
+
return this.request({
|
|
917
|
+
method: 'DELETE',
|
|
918
|
+
url: `/applications/${application_id}/commands/${command_id}`
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
bulkOverwriteGlobalApplicationCommands(application_id, data) {
|
|
922
|
+
return this.request({
|
|
923
|
+
method: 'PUT',
|
|
924
|
+
url: `/applications/${application_id}/commands`,
|
|
925
|
+
data
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
getGuildApplicationCommands(application_id, guild_id, params) {
|
|
929
|
+
return this.request({
|
|
930
|
+
method: 'GET',
|
|
931
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands`,
|
|
932
|
+
params
|
|
933
|
+
});
|
|
934
|
+
}
|
|
935
|
+
createGuildApplicationCommand(application_id, guild_id, data) {
|
|
936
|
+
return this.request({
|
|
937
|
+
method: 'POST',
|
|
938
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands`,
|
|
939
|
+
data
|
|
940
|
+
});
|
|
941
|
+
}
|
|
942
|
+
getGuildApplicationCommand(application_id, guild_id, command_id) {
|
|
943
|
+
return this.request({
|
|
944
|
+
method: 'GET',
|
|
945
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/${command_id}`
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
editGuildApplicationCommand(application_id, guild_id, command_id, data) {
|
|
949
|
+
return this.request({
|
|
950
|
+
method: 'PATCH',
|
|
951
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/${command_id}`,
|
|
952
|
+
data
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
deleteGuildApplicationCommand(application_id, guild_id, command_id) {
|
|
956
|
+
return this.request({
|
|
957
|
+
method: 'DELETE',
|
|
958
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/${command_id}`
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
bulkOverwriteGuildApplicationCommands(application_id, guild_id, data) {
|
|
962
|
+
return this.request({
|
|
963
|
+
method: 'PUT',
|
|
964
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands`,
|
|
965
|
+
data
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
getGuildApplicationCommandPermissions(application_id, guild_id) {
|
|
969
|
+
return this.request({
|
|
970
|
+
method: 'GET',
|
|
971
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/permissions`
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
getApplicationCommandPermissions(application_id, guild_id, command_id) {
|
|
975
|
+
return this.request({
|
|
976
|
+
method: 'GET',
|
|
977
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/${command_id}/permissions`
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
editApplicationCommandPermissions(application_id, guild_id, command_id, data) {
|
|
981
|
+
return this.request({
|
|
982
|
+
method: 'PUT',
|
|
983
|
+
url: `/applications/${application_id}/guilds/${guild_id}/commands/${command_id}/permissions`,
|
|
984
|
+
data
|
|
985
|
+
});
|
|
986
|
+
}
|
|
842
987
|
}
|
|
843
988
|
|
|
844
989
|
export { API_URL, CDN_URL, DCAPI };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/discord",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.14",
|
|
4
4
|
"description": "discord platform connection",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"type": "git",
|
|
66
66
|
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
69
|
-
}
|
|
68
|
+
"gitHead": "c6aa5616afe091a37610dad22fbb2d2618d943b8"
|
|
69
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013-present, Yuxi (Evan) You
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIdED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
-
THE SOFTWARE.
|