disgroove 2.2.2 → 2.2.3-dev.4f98e3d
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 +2 -2
- package/dist/lib/Client.d.ts +69 -77
- package/dist/lib/Client.js +204 -95
- package/dist/lib/gateway/Shard.d.ts +1 -0
- package/dist/lib/gateway/Shard.js +10 -4
- package/dist/lib/transformers/ApplicationCommands.d.ts +7 -0
- package/dist/lib/transformers/ApplicationCommands.js +90 -0
- package/dist/lib/transformers/ApplicationRoleConnectionMetadatas.d.ts +5 -0
- package/dist/lib/transformers/ApplicationRoleConnectionMetadatas.js +26 -0
- package/dist/lib/transformers/Applications.d.ts +0 -3
- package/dist/lib/transformers/Applications.js +0 -114
- package/dist/lib/transformers/AuditLogs.js +3 -3
- package/dist/lib/transformers/AutoModeration.d.ts +5 -1
- package/dist/lib/transformers/AutoModeration.js +44 -32
- package/dist/lib/transformers/Guilds.js +16 -0
- package/dist/lib/transformers/Presences.d.ts +0 -3
- package/dist/lib/transformers/Presences.js +52 -44
- package/dist/lib/transformers/Users.js +16 -2
- package/dist/lib/transformers/index.d.ts +2 -0
- package/dist/lib/transformers/index.js +2 -0
- package/dist/lib/types/guild.d.ts +3 -1
- package/dist/lib/types/user.d.ts +2 -2
- package/dist/lib/utils/errors.js +4 -4
- package/dist/lib/utils/formatters.d.ts +7 -0
- package/dist/lib/utils/formatters.js +7 -1
- package/dist/lib/utils/index.d.ts +0 -1
- package/dist/lib/utils/index.js +0 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/lib/utils/Util.d.ts +0 -4
- package/dist/lib/utils/Util.js +0 -63
package/dist/lib/Client.js
CHANGED
@@ -5,13 +5,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.Client = void 0;
|
7
7
|
const constants_1 = require("./constants");
|
8
|
-
const utils_1 = require("./utils");
|
9
8
|
const rest_1 = require("./rest");
|
10
9
|
const node_events_1 = __importDefault(require("node:events"));
|
11
10
|
const gateway_1 = require("./gateway");
|
12
11
|
const transformers_1 = require("./transformers");
|
13
12
|
class Client extends node_events_1.default {
|
14
13
|
token;
|
14
|
+
properties;
|
15
15
|
compress;
|
16
16
|
largeThreshold;
|
17
17
|
presence;
|
@@ -20,7 +20,6 @@ class Client extends node_events_1.default {
|
|
20
20
|
auth;
|
21
21
|
shards;
|
22
22
|
rest;
|
23
|
-
util;
|
24
23
|
guildShardMap;
|
25
24
|
user;
|
26
25
|
guilds;
|
@@ -29,6 +28,7 @@ class Client extends node_events_1.default {
|
|
29
28
|
constructor(token, options) {
|
30
29
|
super();
|
31
30
|
this.token = token;
|
31
|
+
this.properties = options?.gateway?.properties;
|
32
32
|
this.compress = options?.gateway?.compress;
|
33
33
|
this.largeThreshold = options?.gateway?.largeThreshold;
|
34
34
|
this.presence = options?.gateway?.presence;
|
@@ -37,12 +37,11 @@ class Client extends node_events_1.default {
|
|
37
37
|
? Array.isArray(options.gateway.intents)
|
38
38
|
? options.gateway.intents.reduce((sum, num) => sum + num, 0)
|
39
39
|
: options.gateway.intents
|
40
|
-
:
|
40
|
+
: 0;
|
41
41
|
this.shardsCount = options?.shardsCount ?? "auto";
|
42
42
|
this.auth = options?.auth ?? "Bot";
|
43
43
|
this.shards = new gateway_1.ShardManager();
|
44
44
|
this.rest = new rest_1.RequestManager(token, this.auth);
|
45
|
-
this.util = new utils_1.Util();
|
46
45
|
this.guildShardMap = {};
|
47
46
|
this.user = null;
|
48
47
|
this.guilds = new Map();
|
@@ -118,16 +117,38 @@ class Client extends node_events_1.default {
|
|
118
117
|
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands */
|
119
118
|
async bulkEditGlobalApplicationCommands(applicationID, commands) {
|
120
119
|
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommands(applicationID), {
|
121
|
-
json: commands.map((command) =>
|
120
|
+
json: commands.map((command) => ({
|
121
|
+
id: command.id,
|
122
|
+
name: command.name,
|
123
|
+
name_localizations: command.nameLocalizations,
|
124
|
+
description: command.description,
|
125
|
+
description_localizations: command.descriptionLocalizations,
|
126
|
+
options: command.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
127
|
+
default_member_permissions: command.defaultMemberPermissions,
|
128
|
+
integration_types: command.integrationTypes,
|
129
|
+
contexts: command.contexts,
|
130
|
+
type: command.type,
|
131
|
+
nsfw: command.nsfw,
|
132
|
+
})),
|
122
133
|
});
|
123
|
-
return response.map((c) => transformers_1.
|
134
|
+
return response.map((c) => transformers_1.ApplicationCommands.applicationCommandFromRaw(c));
|
124
135
|
}
|
125
136
|
/** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
|
126
137
|
async bulkEditGuildApplicationCommands(applicationID, guildID, commands) {
|
127
138
|
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationGuildCommands(applicationID, guildID), {
|
128
|
-
json: commands.map((command) =>
|
139
|
+
json: commands.map((command) => ({
|
140
|
+
id: command.id,
|
141
|
+
name: command.name,
|
142
|
+
name_localizations: command.nameLocalizations,
|
143
|
+
description: command.description,
|
144
|
+
description_localizations: command.descriptionLocalizations,
|
145
|
+
options: command.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
146
|
+
default_member_permissions: command.defaultMemberPermissions,
|
147
|
+
type: command.type,
|
148
|
+
nsfw: command.nsfw,
|
149
|
+
})),
|
129
150
|
});
|
130
|
-
return response.map((c) => transformers_1.
|
151
|
+
return response.map((c) => transformers_1.ApplicationCommands.applicationCommandFromRaw(c));
|
131
152
|
}
|
132
153
|
/** https://discord.com/developers/docs/topics/gateway#connections */
|
133
154
|
async connect() {
|
@@ -150,15 +171,10 @@ class Client extends node_events_1.default {
|
|
150
171
|
name: options.name,
|
151
172
|
event_type: options.eventType,
|
152
173
|
trigger_type: options.triggerType,
|
153
|
-
trigger_metadata: options.triggerMetadata
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
channel_id: action.metadata.channelID,
|
158
|
-
duration_seconds: action.metadata.durationSeconds,
|
159
|
-
custom_message: action.metadata.customMessage,
|
160
|
-
},
|
161
|
-
})),
|
174
|
+
trigger_metadata: options.triggerMetadata !== undefined
|
175
|
+
? transformers_1.AutoModeration.triggerMetadataToRaw(options.triggerMetadata)
|
176
|
+
: undefined,
|
177
|
+
actions: options.actions.map((action) => transformers_1.AutoModeration.actionToRaw(action)),
|
162
178
|
enabled: options.enabled,
|
163
179
|
exempt_roles: options.exemptRoles,
|
164
180
|
exempt_channels: options.exemptChannels,
|
@@ -240,12 +256,23 @@ class Client extends node_events_1.default {
|
|
240
256
|
/** https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
|
241
257
|
async createGlobalApplicationCommand(applicationID, options) {
|
242
258
|
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationCommands(applicationID), {
|
243
|
-
json:
|
259
|
+
json: {
|
260
|
+
name: options.name,
|
261
|
+
name_localizations: options.nameLocalizations,
|
262
|
+
description: options.description,
|
263
|
+
description_localizations: options.descriptionLocalizations,
|
264
|
+
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
265
|
+
default_member_permissions: options.defaultMemberPermissions,
|
266
|
+
integration_types: options.integrationTypes,
|
267
|
+
contexts: options.contexts,
|
268
|
+
type: options.type,
|
269
|
+
nsfw: options.nsfw,
|
270
|
+
},
|
244
271
|
});
|
245
|
-
return transformers_1.
|
272
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
246
273
|
}
|
247
274
|
/** https://discord.com/developers/docs/resources/user#create-group-dm */
|
248
|
-
async
|
275
|
+
async createGroup(options) {
|
249
276
|
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.userChannels(), {
|
250
277
|
json: {
|
251
278
|
access_tokens: options.accessTokens,
|
@@ -289,9 +316,18 @@ class Client extends node_events_1.default {
|
|
289
316
|
/** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
|
290
317
|
async createGuildApplicationCommand(applicationID, guildID, options) {
|
291
318
|
const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationGuildCommands(applicationID, guildID), {
|
292
|
-
json:
|
319
|
+
json: {
|
320
|
+
name: options.name,
|
321
|
+
name_localizations: options.nameLocalizations,
|
322
|
+
description: options.description,
|
323
|
+
description_localizations: options.descriptionLocalizations,
|
324
|
+
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
325
|
+
default_member_permissions: options.defaultMemberPermissions,
|
326
|
+
type: options.type,
|
327
|
+
nsfw: options.nsfw,
|
328
|
+
},
|
293
329
|
});
|
294
|
-
return transformers_1.
|
330
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
295
331
|
}
|
296
332
|
/** https://discord.com/developers/docs/resources/guild#create-guild-ban */
|
297
333
|
createGuildBan(guildID, userID, options, reason) {
|
@@ -540,7 +576,14 @@ class Client extends node_events_1.default {
|
|
540
576
|
replied_user: options.allowedMentions.repliedUser,
|
541
577
|
}
|
542
578
|
: undefined,
|
543
|
-
message_reference: options.messageReference
|
579
|
+
message_reference: options.messageReference !== undefined
|
580
|
+
? {
|
581
|
+
message_id: options.messageReference.messageID,
|
582
|
+
channel_id: options.messageReference.channelID,
|
583
|
+
guild_id: options.messageReference.guildID,
|
584
|
+
fail_if_not_exists: options.messageReference.failIfNotExists,
|
585
|
+
}
|
586
|
+
: undefined,
|
544
587
|
components: options.components !== undefined
|
545
588
|
? transformers_1.Channels.componentsToRaw(options.components)
|
546
589
|
: undefined,
|
@@ -605,19 +648,20 @@ class Client extends node_events_1.default {
|
|
605
648
|
content: options.message.content,
|
606
649
|
embeds: options.message.embeds?.map((embed) => transformers_1.Channels.embedToRaw(embed)),
|
607
650
|
allowed_mentions: options.message.allowedMentions !== undefined
|
608
|
-
?
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
}
|
615
|
-
: null
|
651
|
+
? {
|
652
|
+
parse: options.message.allowedMentions.parse,
|
653
|
+
roles: options.message.allowedMentions.roles,
|
654
|
+
users: options.message.allowedMentions.users,
|
655
|
+
replied_user: options.message.allowedMentions.repliedUser,
|
656
|
+
}
|
616
657
|
: undefined,
|
658
|
+
sticker_ids: options.message.stickerIDs,
|
659
|
+
attachments: options.message.attachments,
|
660
|
+
flags: options.message.flags,
|
617
661
|
},
|
618
662
|
applied_tags: options.appliedTags,
|
619
663
|
},
|
620
|
-
files: options.files,
|
664
|
+
files: options.message.files,
|
621
665
|
reason,
|
622
666
|
});
|
623
667
|
return transformers_1.Channels.channelFromRaw(response);
|
@@ -787,15 +831,10 @@ class Client extends node_events_1.default {
|
|
787
831
|
name: options.name,
|
788
832
|
event_type: options.eventType,
|
789
833
|
trigger_type: options.triggerType,
|
790
|
-
trigger_metadata: options.triggerMetadata
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
channel_id: action.metadata.channelID,
|
795
|
-
duration_seconds: action.metadata.durationSeconds,
|
796
|
-
custom_message: action.metadata.customMessage,
|
797
|
-
},
|
798
|
-
})),
|
834
|
+
trigger_metadata: options.triggerMetadata !== undefined
|
835
|
+
? transformers_1.AutoModeration.triggerMetadataToRaw(options.triggerMetadata)
|
836
|
+
: undefined,
|
837
|
+
actions: options.actions?.map((action) => transformers_1.AutoModeration.actionToRaw(action)),
|
799
838
|
enabled: options.enabled,
|
800
839
|
exempt_roles: options.exemptRoles,
|
801
840
|
exempt_channels: options.exemptChannels,
|
@@ -808,7 +847,11 @@ class Client extends node_events_1.default {
|
|
808
847
|
async editApplicationCommandPermissions(applicationID, guildID, commandID, options) {
|
809
848
|
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationID, guildID, commandID), {
|
810
849
|
json: {
|
811
|
-
permissions: options.permissions.map((permission) =>
|
850
|
+
permissions: options.permissions.map((permission) => ({
|
851
|
+
id: permission.type,
|
852
|
+
type: permission.type,
|
853
|
+
permission: permission.permission,
|
854
|
+
})),
|
812
855
|
},
|
813
856
|
});
|
814
857
|
return transformers_1.Guilds.guildApplicationCommandPermissionsFromRaw(response);
|
@@ -818,12 +861,14 @@ class Client extends node_events_1.default {
|
|
818
861
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channel(channelID), {
|
819
862
|
json: {
|
820
863
|
name: options.name,
|
864
|
+
icon: options.icon,
|
821
865
|
type: options.type,
|
822
866
|
position: options.position,
|
823
867
|
topic: options.topic,
|
824
868
|
nsfw: options.nsfw,
|
825
869
|
rate_limit_per_user: options.rateLimitPerUser,
|
826
870
|
bitrate: options.bitrate,
|
871
|
+
user_limit: options.userLimit,
|
827
872
|
permission_overwrites: options.permissionOverwrites,
|
828
873
|
parent_id: options.parentID,
|
829
874
|
rtc_region: options.rtcRegion,
|
@@ -831,7 +876,14 @@ class Client extends node_events_1.default {
|
|
831
876
|
default_auto_archive_duration: options.defaultAutoArchiveDuration,
|
832
877
|
flags: options.flags,
|
833
878
|
available_tags: options.availableTags,
|
834
|
-
default_reaction_emoji: options.defaultReactionEmoji
|
879
|
+
default_reaction_emoji: options.defaultReactionEmoji !== undefined
|
880
|
+
? options.defaultReactionEmoji !== null
|
881
|
+
? {
|
882
|
+
emoji_id: options.defaultReactionEmoji.emojiID,
|
883
|
+
emoji_name: options.defaultReactionEmoji.emojiName,
|
884
|
+
}
|
885
|
+
: null
|
886
|
+
: undefined,
|
835
887
|
default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
|
836
888
|
default_sort_order: options.defaultSortOrder,
|
837
889
|
default_forum_layout: options.defaultForumLayout,
|
@@ -902,6 +954,16 @@ class Client extends node_events_1.default {
|
|
902
954
|
description: options.description,
|
903
955
|
role_connections_verification_url: options.roleConnectionsVerificationURL,
|
904
956
|
install_params: options.installParams,
|
957
|
+
integration_types_config: options.integrationTypesConfig !== undefined
|
958
|
+
? {
|
959
|
+
"0": {
|
960
|
+
oauth2_install_params: options.integrationTypesConfig?.[0].oauth2InstallParams,
|
961
|
+
},
|
962
|
+
"1": {
|
963
|
+
oauth2_install_params: options.integrationTypesConfig?.[1].oauth2InstallParams,
|
964
|
+
},
|
965
|
+
}
|
966
|
+
: undefined,
|
905
967
|
flags: options.flags,
|
906
968
|
icon: options.icon,
|
907
969
|
cover_image: options.coverImage,
|
@@ -914,16 +976,25 @@ class Client extends node_events_1.default {
|
|
914
976
|
/** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
|
915
977
|
async editGlobalApplicationCommand(applicationID, commandID, options) {
|
916
978
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCommand(applicationID, commandID), {
|
917
|
-
json:
|
979
|
+
json: {
|
980
|
+
name: options.name,
|
981
|
+
name_localizations: options.nameLocalizations,
|
982
|
+
description: options.description,
|
983
|
+
description_localizations: options.descriptionLocalizations,
|
984
|
+
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
985
|
+
default_member_permissions: options.defaultMemberPermissions,
|
986
|
+
integration_types: options.integrationTypes,
|
987
|
+
contexts: options.contexts,
|
988
|
+
nsfw: options.nsfw,
|
989
|
+
},
|
918
990
|
});
|
919
|
-
return transformers_1.
|
991
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
920
992
|
}
|
921
993
|
/** https://discord.com/developers/docs/resources/guild#modify-guild */
|
922
994
|
async editGuild(guildID, options, reason) {
|
923
995
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guild(guildID), {
|
924
996
|
json: {
|
925
997
|
name: options.name,
|
926
|
-
region: options.region,
|
927
998
|
verification_level: options.verificationLevel,
|
928
999
|
default_message_notifications: options.defaultMessageNotifications,
|
929
1000
|
explicit_content_filter: options.explicitContentFilter,
|
@@ -951,9 +1022,17 @@ class Client extends node_events_1.default {
|
|
951
1022
|
/** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
|
952
1023
|
async editGuildApplicationCommand(applicationID, guildID, commandID, options) {
|
953
1024
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationGuildCommand(applicationID, guildID, commandID), {
|
954
|
-
json:
|
1025
|
+
json: {
|
1026
|
+
name: options.name,
|
1027
|
+
name_localizations: options.nameLocalizations,
|
1028
|
+
description: options.description,
|
1029
|
+
description_localizations: options.descriptionLocalizations,
|
1030
|
+
options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
|
1031
|
+
default_member_permissions: options.defaultMemberPermissions,
|
1032
|
+
nsfw: options.nsfw,
|
1033
|
+
},
|
955
1034
|
});
|
956
|
-
return transformers_1.
|
1035
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
957
1036
|
}
|
958
1037
|
/** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
|
959
1038
|
async editGuildEmoji(guildID, emojiID, options, reason) {
|
@@ -1037,9 +1116,10 @@ class Client extends node_events_1.default {
|
|
1037
1116
|
return transformers_1.Roles.roleFromRaw(response);
|
1038
1117
|
}
|
1039
1118
|
/** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */
|
1040
|
-
async editGuildRolePositions(guildID, options) {
|
1119
|
+
async editGuildRolePositions(guildID, options, reason) {
|
1041
1120
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRoles(guildID), {
|
1042
1121
|
json: options,
|
1122
|
+
reason,
|
1043
1123
|
});
|
1044
1124
|
return response.map((role) => transformers_1.Roles.roleFromRaw(role));
|
1045
1125
|
}
|
@@ -1089,7 +1169,12 @@ class Client extends node_events_1.default {
|
|
1089
1169
|
const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWelcomeScreen(guildID), {
|
1090
1170
|
json: {
|
1091
1171
|
enabled: options.enabled,
|
1092
|
-
welcome_channels: options.welcomeChannels
|
1172
|
+
welcome_channels: options.welcomeChannels?.map((welcomeChannel) => ({
|
1173
|
+
channel_id: welcomeChannel.channelID,
|
1174
|
+
description: welcomeChannel.description,
|
1175
|
+
emoji_id: welcomeChannel.emojiID,
|
1176
|
+
emoji_name: welcomeChannel.emojiName,
|
1177
|
+
})),
|
1093
1178
|
description: options.description,
|
1094
1179
|
},
|
1095
1180
|
reason,
|
@@ -1182,8 +1267,22 @@ class Client extends node_events_1.default {
|
|
1182
1267
|
? transformers_1.Channels.componentsToRaw(options.components)
|
1183
1268
|
: null
|
1184
1269
|
: undefined,
|
1185
|
-
attachments: options.attachments?.map((attachment) =>
|
1186
|
-
|
1270
|
+
attachments: options.attachments?.map((attachment) => ({
|
1271
|
+
id: attachment.id,
|
1272
|
+
filename: attachment.filename,
|
1273
|
+
title: attachment.title,
|
1274
|
+
description: attachment.description,
|
1275
|
+
content_type: attachment.contentType,
|
1276
|
+
size: attachment.size,
|
1277
|
+
url: attachment.url,
|
1278
|
+
proxy_url: attachment.proxyURL,
|
1279
|
+
height: attachment.height,
|
1280
|
+
width: attachment.width,
|
1281
|
+
ephemeral: attachment.ephemeral,
|
1282
|
+
duration_secs: attachment.durationSecs,
|
1283
|
+
waveform: attachment.waveform,
|
1284
|
+
flags: attachment.flags,
|
1285
|
+
})),
|
1187
1286
|
},
|
1188
1287
|
files: options.files,
|
1189
1288
|
query: {
|
@@ -1215,8 +1314,22 @@ class Client extends node_events_1.default {
|
|
1215
1314
|
? transformers_1.Channels.componentsToRaw(options.components)
|
1216
1315
|
: null
|
1217
1316
|
: undefined,
|
1218
|
-
attachments: options.attachments?.map((attachment) =>
|
1219
|
-
|
1317
|
+
attachments: options.attachments?.map((attachment) => ({
|
1318
|
+
id: attachment.id,
|
1319
|
+
filename: attachment.filename,
|
1320
|
+
title: attachment.title,
|
1321
|
+
description: attachment.description,
|
1322
|
+
content_type: attachment.contentType,
|
1323
|
+
size: attachment.size,
|
1324
|
+
url: attachment.url,
|
1325
|
+
proxy_url: attachment.proxyURL,
|
1326
|
+
height: attachment.height,
|
1327
|
+
width: attachment.width,
|
1328
|
+
ephemeral: attachment.ephemeral,
|
1329
|
+
duration_secs: attachment.durationSecs,
|
1330
|
+
waveform: attachment.waveform,
|
1331
|
+
flags: attachment.flags,
|
1332
|
+
})),
|
1220
1333
|
},
|
1221
1334
|
files: options.files,
|
1222
1335
|
query: {
|
@@ -1231,7 +1344,6 @@ class Client extends node_events_1.default {
|
|
1231
1344
|
json: {
|
1232
1345
|
channel_id: options.channelID,
|
1233
1346
|
suppress: options.suppress,
|
1234
|
-
requestToSpeakTimestamp: options.requestToSpeakTimestamp,
|
1235
1347
|
},
|
1236
1348
|
});
|
1237
1349
|
}
|
@@ -1270,8 +1382,22 @@ class Client extends node_events_1.default {
|
|
1270
1382
|
? transformers_1.Channels.componentsToRaw(options.components)
|
1271
1383
|
: null
|
1272
1384
|
: undefined,
|
1273
|
-
attachments: options.attachments?.map((attachment) =>
|
1274
|
-
|
1385
|
+
attachments: options.attachments?.map((attachment) => ({
|
1386
|
+
id: attachment.id,
|
1387
|
+
filename: attachment.filename,
|
1388
|
+
title: attachment.title,
|
1389
|
+
description: attachment.description,
|
1390
|
+
content_type: attachment.contentType,
|
1391
|
+
size: attachment.size,
|
1392
|
+
url: attachment.url,
|
1393
|
+
proxy_url: attachment.proxyURL,
|
1394
|
+
height: attachment.height,
|
1395
|
+
width: attachment.width,
|
1396
|
+
ephemeral: attachment.ephemeral,
|
1397
|
+
duration_secs: attachment.durationSecs,
|
1398
|
+
waveform: attachment.waveform,
|
1399
|
+
flags: attachment.flags,
|
1400
|
+
})),
|
1275
1401
|
},
|
1276
1402
|
files: options.files,
|
1277
1403
|
query: {
|
@@ -1423,14 +1549,7 @@ class Client extends node_events_1.default {
|
|
1423
1549
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
|
1424
1550
|
async getApplicationRoleConnectionMetadataRecords(applicationID) {
|
1425
1551
|
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationID));
|
1426
|
-
return response.map((applicationRoleConnectionMetadata) => (
|
1427
|
-
type: applicationRoleConnectionMetadata.type,
|
1428
|
-
key: applicationRoleConnectionMetadata.key,
|
1429
|
-
name: applicationRoleConnectionMetadata.name,
|
1430
|
-
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
1431
|
-
description: applicationRoleConnectionMetadata.description,
|
1432
|
-
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
1433
|
-
}));
|
1552
|
+
return response.map((applicationRoleConnectionMetadata) => transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(applicationRoleConnectionMetadata));
|
1434
1553
|
}
|
1435
1554
|
/** https://discord.com/developers/docs/resources/channel#get-channel */
|
1436
1555
|
async getChannel(channelID) {
|
@@ -1463,14 +1582,7 @@ class Client extends node_events_1.default {
|
|
1463
1582
|
return {
|
1464
1583
|
platformName: response.platform_name,
|
1465
1584
|
platformUsername: response.platform_username,
|
1466
|
-
metadata:
|
1467
|
-
type: response.metadata.type,
|
1468
|
-
key: response.metadata.key,
|
1469
|
-
name: response.metadata.name,
|
1470
|
-
nameLocalizations: response.metadata.name_localizations,
|
1471
|
-
description: response.metadata.description,
|
1472
|
-
descriptionLocalizations: response.metadata.description_localizations,
|
1473
|
-
},
|
1585
|
+
metadata: transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(response.metadata),
|
1474
1586
|
};
|
1475
1587
|
}
|
1476
1588
|
/** https://discord.com/developers/docs/resources/user#get-current-user-guild-member */
|
@@ -1530,7 +1642,7 @@ class Client extends node_events_1.default {
|
|
1530
1642
|
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
|
1531
1643
|
async getGlobalApplicationCommand(applicationID, commandID) {
|
1532
1644
|
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommand(applicationID, commandID));
|
1533
|
-
return transformers_1.
|
1645
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
1534
1646
|
}
|
1535
1647
|
/** https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
|
1536
1648
|
async getGlobalApplicationCommands(applicationID, options) {
|
@@ -1539,7 +1651,7 @@ class Client extends node_events_1.default {
|
|
1539
1651
|
with_localizations: options.withLocalizations,
|
1540
1652
|
},
|
1541
1653
|
});
|
1542
|
-
return response.map((applicationCommand) => transformers_1.
|
1654
|
+
return response.map((applicationCommand) => transformers_1.ApplicationCommands.applicationCommandFromRaw(applicationCommand));
|
1543
1655
|
}
|
1544
1656
|
/** https://discord.com/developers/docs/resources/guild#get-guild */
|
1545
1657
|
async getGuild(guildID, options) {
|
@@ -1560,12 +1672,21 @@ class Client extends node_events_1.default {
|
|
1560
1672
|
with_counts: options?.withCounts,
|
1561
1673
|
},
|
1562
1674
|
});
|
1563
|
-
return response.map((guild) =>
|
1675
|
+
return response.map((guild) => ({
|
1676
|
+
id: guild.id,
|
1677
|
+
name: guild.name,
|
1678
|
+
icon: guild.icon,
|
1679
|
+
owner: guild.owner,
|
1680
|
+
permissions: guild.permissions,
|
1681
|
+
features: guild.features,
|
1682
|
+
approximate_member_count: guild.approximate_member_count,
|
1683
|
+
approximate_presence_count: guild.approximate_presence_count,
|
1684
|
+
}));
|
1564
1685
|
}
|
1565
1686
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
|
1566
1687
|
async getGuildApplicationCommand(applicationID, guildID, commandID) {
|
1567
1688
|
const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommand(applicationID, guildID, commandID));
|
1568
|
-
return transformers_1.
|
1689
|
+
return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
|
1569
1690
|
}
|
1570
1691
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
|
1571
1692
|
async getGuildApplicationCommands(applicationID, guildID, options) {
|
@@ -1574,7 +1695,7 @@ class Client extends node_events_1.default {
|
|
1574
1695
|
with_localizations: options?.withLocalizations,
|
1575
1696
|
},
|
1576
1697
|
});
|
1577
|
-
return response.map((applicationCommand) => transformers_1.
|
1698
|
+
return response.map((applicationCommand) => transformers_1.ApplicationCommands.applicationCommandFromRaw(applicationCommand));
|
1578
1699
|
}
|
1579
1700
|
/** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
|
1580
1701
|
async getGuildApplicationCommandPermissions(applicationID, guildID) {
|
@@ -2066,14 +2187,7 @@ class Client extends node_events_1.default {
|
|
2066
2187
|
/** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
|
2067
2188
|
async updateApplicationRoleConnectionMetadataRecords(applicationID) {
|
2068
2189
|
const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationRoleConnectionMetadata(applicationID));
|
2069
|
-
return response.map((applicationRoleConnectionMetadata) => (
|
2070
|
-
type: applicationRoleConnectionMetadata.type,
|
2071
|
-
key: applicationRoleConnectionMetadata.key,
|
2072
|
-
name: applicationRoleConnectionMetadata.name,
|
2073
|
-
nameLocalizations: applicationRoleConnectionMetadata.name_localizations,
|
2074
|
-
description: applicationRoleConnectionMetadata.description,
|
2075
|
-
descriptionLocalizations: applicationRoleConnectionMetadata.description_localizations,
|
2076
|
-
}));
|
2190
|
+
return response.map((applicationRoleConnectionMetadata) => transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(applicationRoleConnectionMetadata));
|
2077
2191
|
}
|
2078
2192
|
/** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
|
2079
2193
|
async updateCurrentApplicationRoleConnection(applicationID, options) {
|
@@ -2081,20 +2195,15 @@ class Client extends node_events_1.default {
|
|
2081
2195
|
json: {
|
2082
2196
|
platform_name: options.platformName,
|
2083
2197
|
platform_username: options.platformUsername,
|
2084
|
-
metadata: options.metadata
|
2198
|
+
metadata: options.metadata !== undefined
|
2199
|
+
? transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataToRaw(options.metadata)
|
2200
|
+
: undefined,
|
2085
2201
|
},
|
2086
2202
|
});
|
2087
2203
|
return {
|
2088
2204
|
platformName: response.platform_name,
|
2089
2205
|
platformUsername: response.platform_username,
|
2090
|
-
metadata:
|
2091
|
-
type: response.metadata.type,
|
2092
|
-
key: response.metadata.key,
|
2093
|
-
name: response.metadata.name,
|
2094
|
-
nameLocalizations: response.metadata.name_localizations,
|
2095
|
-
description: response.metadata.description,
|
2096
|
-
descriptionLocalizations: response.metadata.description_localizations,
|
2097
|
-
},
|
2206
|
+
metadata: transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(response.metadata),
|
2098
2207
|
};
|
2099
2208
|
}
|
2100
2209
|
/** https://discord.com/developers/docs/resources/channel#unpin-message */
|
@@ -38,12 +38,14 @@ class Shard {
|
|
38
38
|
client;
|
39
39
|
ws;
|
40
40
|
sessionID;
|
41
|
+
resumeGatewayURL;
|
41
42
|
constructor(id, client) {
|
42
43
|
this.id = id;
|
43
44
|
this.heartbeatInterval = null;
|
44
45
|
this.client = client;
|
45
46
|
this.ws = new ws_1.default("wss://gateway.discord.gg/?v=10&encoding=json", client.ws);
|
46
47
|
this.sessionID = null;
|
48
|
+
this.resumeGatewayURL = null;
|
47
49
|
}
|
48
50
|
/** https://discord.com/developers/docs/topics/gateway#connections */
|
49
51
|
connect() {
|
@@ -91,6 +93,7 @@ class Shard {
|
|
91
93
|
case constants_1.GatewayEvents.Ready:
|
92
94
|
{
|
93
95
|
this.sessionID = packet.d.session_id;
|
96
|
+
this.resumeGatewayURL = packet.d.resume_gateway_url;
|
94
97
|
this.client.user = transformers_1.Users.userFromRaw(packet.d.user);
|
95
98
|
this.client.application = packet.d.application;
|
96
99
|
this.client.emit("ready");
|
@@ -500,9 +503,9 @@ class Shard {
|
|
500
503
|
this.identify({
|
501
504
|
token: this.client.token,
|
502
505
|
properties: {
|
503
|
-
os: process.platform,
|
504
|
-
browser: pkg.name,
|
505
|
-
device: pkg.name,
|
506
|
+
os: this.client.properties?.os ?? process.platform,
|
507
|
+
browser: this.client.properties?.browser ?? pkg.name,
|
508
|
+
device: this.client.properties?.device ?? pkg.name,
|
506
509
|
},
|
507
510
|
compress: this.client.compress,
|
508
511
|
largeThreshold: this.client.largeThreshold,
|
@@ -542,9 +545,12 @@ class Shard {
|
|
542
545
|
case constants_1.GatewayOPCodes.Hello:
|
543
546
|
{
|
544
547
|
this.heartbeatInterval = setInterval(() => this.heartbeat(null), packet.d.heartbeat_interval);
|
545
|
-
this.client.emit("hello");
|
548
|
+
this.client.emit("hello", packet.d.heartbeat_interval);
|
546
549
|
}
|
547
550
|
break;
|
551
|
+
case constants_1.GatewayOPCodes.HeartbeatACK:
|
552
|
+
this.client.emit("heartbeatACK");
|
553
|
+
break;
|
548
554
|
}
|
549
555
|
}
|
550
556
|
onWebSocketError(err) {
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { RawApplicationCommand, ApplicationCommand, ApplicationCommandOption, RawApplicationCommandOption } from "../types/application-command";
|
2
|
+
export declare class ApplicationCommands {
|
3
|
+
static applicationCommandFromRaw(command: RawApplicationCommand): ApplicationCommand;
|
4
|
+
static applicationCommandToRaw(command: ApplicationCommand): RawApplicationCommand;
|
5
|
+
static optionToRaw(option: ApplicationCommandOption): RawApplicationCommandOption;
|
6
|
+
static optionFromRaw(option: RawApplicationCommandOption): ApplicationCommandOption;
|
7
|
+
}
|