disgroove 2.2.2 → 2.2.3-dev.933ac5e

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.
@@ -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
- : constants_1.GatewayIntents.AllNonPrivileged;
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,40 @@ 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) => this.util.partialApplicationCommandToRaw(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
+ default_permissions: command.defaultPermission,
129
+ integration_types: command.integrationTypes,
130
+ contexts: command.contexts,
131
+ type: command.type,
132
+ nsfw: command.nsfw,
133
+ })),
122
134
  });
123
- return response.map((c) => transformers_1.Applications.applicationCommandFromRaw(c));
135
+ return response.map((c) => transformers_1.ApplicationCommands.applicationCommandFromRaw(c));
124
136
  }
125
137
  /** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
126
138
  async bulkEditGuildApplicationCommands(applicationID, guildID, commands) {
127
139
  const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationGuildCommands(applicationID, guildID), {
128
- json: commands.map((command) => this.util.partialApplicationCommandToRaw(command)),
140
+ json: commands.map((command) => ({
141
+ id: command.id,
142
+ name: command.name,
143
+ name_localizations: command.nameLocalizations,
144
+ description: command.description,
145
+ description_localizations: command.descriptionLocalizations,
146
+ options: command.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
147
+ default_member_permissions: command.defaultMemberPermissions,
148
+ default_permissions: command.defaultPermission,
149
+ type: command.type,
150
+ nsfw: command.nsfw,
151
+ })),
129
152
  });
130
- return response.map((c) => transformers_1.Applications.applicationCommandFromRaw(c));
153
+ return response.map((c) => transformers_1.ApplicationCommands.applicationCommandFromRaw(c));
131
154
  }
132
155
  /** https://discord.com/developers/docs/topics/gateway#connections */
133
156
  async connect() {
@@ -150,7 +173,16 @@ class Client extends node_events_1.default {
150
173
  name: options.name,
151
174
  event_type: options.eventType,
152
175
  trigger_type: options.triggerType,
153
- trigger_metadata: options.triggerMetadata,
176
+ trigger_metadata: options.triggerMetadata !== undefined
177
+ ? {
178
+ keyword_filter: options.triggerMetadata.keywordFilter,
179
+ regex_patterns: options.triggerMetadata.regexPatterns,
180
+ presets: options.triggerMetadata.presets,
181
+ allow_list: options.triggerMetadata.allowList,
182
+ mention_total_limit: options.triggerMetadata.mentionTotalLimit,
183
+ mention_raid_protection: options.triggerMetadata.mentionRaidProtection,
184
+ }
185
+ : undefined,
154
186
  actions: options.actions.map((action) => ({
155
187
  type: action.type,
156
188
  metadata: {
@@ -240,9 +272,21 @@ class Client extends node_events_1.default {
240
272
  /** https://discord.com/developers/docs/interactions/application-commands#create-global-application-command */
241
273
  async createGlobalApplicationCommand(applicationID, options) {
242
274
  const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationCommands(applicationID), {
243
- json: this.util.partialApplicationCommandToRaw(options),
275
+ json: {
276
+ name: options.name,
277
+ name_localizations: options.nameLocalizations,
278
+ description: options.description,
279
+ description_localizations: options.descriptionLocalizations,
280
+ options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
281
+ default_member_permissions: options.defaultMemberPermissions,
282
+ default_permissions: options.defaultPermission,
283
+ integration_types: options.integrationTypes,
284
+ contexts: options.contexts,
285
+ type: options.type,
286
+ nsfw: options.nsfw,
287
+ },
244
288
  });
245
- return transformers_1.Applications.applicationCommandFromRaw(response);
289
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
246
290
  }
247
291
  /** https://discord.com/developers/docs/resources/user#create-group-dm */
248
292
  async createGroupDM(options) {
@@ -289,9 +333,19 @@ class Client extends node_events_1.default {
289
333
  /** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
290
334
  async createGuildApplicationCommand(applicationID, guildID, options) {
291
335
  const response = await this.rest.request(rest_1.RESTMethods.Post, rest_1.Endpoints.applicationGuildCommands(applicationID, guildID), {
292
- json: this.util.partialApplicationCommandToRaw(options),
336
+ json: {
337
+ name: options.name,
338
+ name_localizations: options.nameLocalizations,
339
+ description: options.description,
340
+ description_localizations: options.descriptionLocalizations,
341
+ options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
342
+ default_member_permissions: options.defaultMemberPermissions,
343
+ default_permissions: options.defaultPermission,
344
+ type: options.type,
345
+ nsfw: options.nsfw,
346
+ },
293
347
  });
294
- return transformers_1.Applications.applicationCommandFromRaw(response);
348
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
295
349
  }
296
350
  /** https://discord.com/developers/docs/resources/guild#create-guild-ban */
297
351
  createGuildBan(guildID, userID, options, reason) {
@@ -540,7 +594,14 @@ class Client extends node_events_1.default {
540
594
  replied_user: options.allowedMentions.repliedUser,
541
595
  }
542
596
  : undefined,
543
- message_reference: options.messageReference,
597
+ message_reference: options.messageReference !== undefined
598
+ ? {
599
+ message_id: options.messageReference.messageID,
600
+ channel_id: options.messageReference.channelID,
601
+ guild_id: options.messageReference.guildID,
602
+ fail_if_not_exists: options.messageReference.failIfNotExists,
603
+ }
604
+ : undefined,
544
605
  components: options.components !== undefined
545
606
  ? transformers_1.Channels.componentsToRaw(options.components)
546
607
  : undefined,
@@ -605,19 +666,20 @@ class Client extends node_events_1.default {
605
666
  content: options.message.content,
606
667
  embeds: options.message.embeds?.map((embed) => transformers_1.Channels.embedToRaw(embed)),
607
668
  allowed_mentions: options.message.allowedMentions !== undefined
608
- ? options.message.allowedMentions !== null
609
- ? {
610
- parse: options.message.allowedMentions.parse,
611
- roles: options.message.allowedMentions.roles,
612
- users: options.message.allowedMentions.users,
613
- replied_user: options.message.allowedMentions.repliedUser,
614
- }
615
- : null
669
+ ? {
670
+ parse: options.message.allowedMentions.parse,
671
+ roles: options.message.allowedMentions.roles,
672
+ users: options.message.allowedMentions.users,
673
+ replied_user: options.message.allowedMentions.repliedUser,
674
+ }
616
675
  : undefined,
676
+ sticker_ids: options.message.stickerIDs,
677
+ attachments: options.message.attachments,
678
+ flags: options.message.flags,
617
679
  },
618
680
  applied_tags: options.appliedTags,
619
681
  },
620
- files: options.files,
682
+ files: options.message.files,
621
683
  reason,
622
684
  });
623
685
  return transformers_1.Channels.channelFromRaw(response);
@@ -787,7 +849,16 @@ class Client extends node_events_1.default {
787
849
  name: options.name,
788
850
  event_type: options.eventType,
789
851
  trigger_type: options.triggerType,
790
- trigger_metadata: options.triggerMetadata,
852
+ trigger_metadata: options.triggerMetadata !== undefined
853
+ ? {
854
+ keyword_filter: options.triggerMetadata.keywordFilter,
855
+ regex_patterns: options.triggerMetadata.regexPatterns,
856
+ presets: options.triggerMetadata.presets,
857
+ allow_list: options.triggerMetadata.allowList,
858
+ mention_total_limit: options.triggerMetadata.mentionTotalLimit,
859
+ mention_raid_protection: options.triggerMetadata.mentionRaidProtection,
860
+ }
861
+ : undefined,
791
862
  actions: options.actions?.map((action) => ({
792
863
  type: action.type,
793
864
  metadata: {
@@ -808,7 +879,11 @@ class Client extends node_events_1.default {
808
879
  async editApplicationCommandPermissions(applicationID, guildID, commandID, options) {
809
880
  const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationID, guildID, commandID), {
810
881
  json: {
811
- permissions: options.permissions.map((permission) => transformers_1.Guilds.guildApplicationCommandPermissionsToRaw(permission)),
882
+ permissions: options.permissions.map((permission) => ({
883
+ id: permission.type,
884
+ type: permission.type,
885
+ permission: permission.permission,
886
+ })),
812
887
  },
813
888
  });
814
889
  return transformers_1.Guilds.guildApplicationCommandPermissionsFromRaw(response);
@@ -818,12 +893,14 @@ class Client extends node_events_1.default {
818
893
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.channel(channelID), {
819
894
  json: {
820
895
  name: options.name,
896
+ icon: options.icon,
821
897
  type: options.type,
822
898
  position: options.position,
823
899
  topic: options.topic,
824
900
  nsfw: options.nsfw,
825
901
  rate_limit_per_user: options.rateLimitPerUser,
826
902
  bitrate: options.bitrate,
903
+ user_limit: options.userLimit,
827
904
  permission_overwrites: options.permissionOverwrites,
828
905
  parent_id: options.parentID,
829
906
  rtc_region: options.rtcRegion,
@@ -831,7 +908,14 @@ class Client extends node_events_1.default {
831
908
  default_auto_archive_duration: options.defaultAutoArchiveDuration,
832
909
  flags: options.flags,
833
910
  available_tags: options.availableTags,
834
- default_reaction_emoji: options.defaultReactionEmoji,
911
+ default_reaction_emoji: options.defaultReactionEmoji !== undefined
912
+ ? options.defaultReactionEmoji !== null
913
+ ? {
914
+ emoji_id: options.defaultReactionEmoji.emojiID,
915
+ emoji_name: options.defaultReactionEmoji.emojiName,
916
+ }
917
+ : null
918
+ : undefined,
835
919
  default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
836
920
  default_sort_order: options.defaultSortOrder,
837
921
  default_forum_layout: options.defaultForumLayout,
@@ -902,6 +986,16 @@ class Client extends node_events_1.default {
902
986
  description: options.description,
903
987
  role_connections_verification_url: options.roleConnectionsVerificationURL,
904
988
  install_params: options.installParams,
989
+ integration_types_config: options.integrationTypesConfig !== undefined
990
+ ? {
991
+ "0": {
992
+ oauth2_install_params: options.integrationTypesConfig?.[0].oauth2InstallParams,
993
+ },
994
+ "1": {
995
+ oauth2_install_params: options.integrationTypesConfig?.[1].oauth2InstallParams,
996
+ },
997
+ }
998
+ : undefined,
905
999
  flags: options.flags,
906
1000
  icon: options.icon,
907
1001
  cover_image: options.coverImage,
@@ -914,16 +1008,26 @@ class Client extends node_events_1.default {
914
1008
  /** https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command */
915
1009
  async editGlobalApplicationCommand(applicationID, commandID, options) {
916
1010
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationCommand(applicationID, commandID), {
917
- json: this.util.partialApplicationCommandToRaw(options),
1011
+ json: {
1012
+ name: options.name,
1013
+ name_localizations: options.nameLocalizations,
1014
+ description: options.description,
1015
+ description_localizations: options.descriptionLocalizations,
1016
+ options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
1017
+ default_member_permissions: options.defaultMemberPermissions,
1018
+ default_permissions: options.defaultPermission,
1019
+ integration_types: options.integrationTypes,
1020
+ contexts: options.contexts,
1021
+ nsfw: options.nsfw,
1022
+ },
918
1023
  });
919
- return transformers_1.Applications.applicationCommandFromRaw(response);
1024
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
920
1025
  }
921
1026
  /** https://discord.com/developers/docs/resources/guild#modify-guild */
922
1027
  async editGuild(guildID, options, reason) {
923
1028
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guild(guildID), {
924
1029
  json: {
925
1030
  name: options.name,
926
- region: options.region,
927
1031
  verification_level: options.verificationLevel,
928
1032
  default_message_notifications: options.defaultMessageNotifications,
929
1033
  explicit_content_filter: options.explicitContentFilter,
@@ -951,9 +1055,18 @@ class Client extends node_events_1.default {
951
1055
  /** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
952
1056
  async editGuildApplicationCommand(applicationID, guildID, commandID, options) {
953
1057
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.applicationGuildCommand(applicationID, guildID, commandID), {
954
- json: this.util.partialApplicationCommandToRaw(options),
1058
+ json: {
1059
+ name: options.name,
1060
+ name_localizations: options.nameLocalizations,
1061
+ description: options.description,
1062
+ description_localizations: options.descriptionLocalizations,
1063
+ options: options.options?.map((option) => transformers_1.ApplicationCommands.optionToRaw(option)),
1064
+ default_member_permissions: options.defaultMemberPermissions,
1065
+ default_permissions: options.defaultPermission,
1066
+ nsfw: options.nsfw,
1067
+ },
955
1068
  });
956
- return transformers_1.Applications.applicationCommandFromRaw(response);
1069
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
957
1070
  }
958
1071
  /** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
959
1072
  async editGuildEmoji(guildID, emojiID, options, reason) {
@@ -1037,9 +1150,10 @@ class Client extends node_events_1.default {
1037
1150
  return transformers_1.Roles.roleFromRaw(response);
1038
1151
  }
1039
1152
  /** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */
1040
- async editGuildRolePositions(guildID, options) {
1153
+ async editGuildRolePositions(guildID, options, reason) {
1041
1154
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildRoles(guildID), {
1042
1155
  json: options,
1156
+ reason,
1043
1157
  });
1044
1158
  return response.map((role) => transformers_1.Roles.roleFromRaw(role));
1045
1159
  }
@@ -1089,7 +1203,12 @@ class Client extends node_events_1.default {
1089
1203
  const response = await this.rest.request(rest_1.RESTMethods.Patch, rest_1.Endpoints.guildWelcomeScreen(guildID), {
1090
1204
  json: {
1091
1205
  enabled: options.enabled,
1092
- welcome_channels: options.welcomeChannels,
1206
+ welcome_channels: options.welcomeChannels?.map((welcomeChannel) => ({
1207
+ channel_id: welcomeChannel.channelID,
1208
+ description: welcomeChannel.description,
1209
+ emoji_id: welcomeChannel.emojiID,
1210
+ emoji_name: welcomeChannel.emojiName,
1211
+ })),
1093
1212
  description: options.description,
1094
1213
  },
1095
1214
  reason,
@@ -1182,8 +1301,22 @@ class Client extends node_events_1.default {
1182
1301
  ? transformers_1.Channels.componentsToRaw(options.components)
1183
1302
  : null
1184
1303
  : undefined,
1185
- attachments: options.attachments?.map((attachment) => transformers_1.Channels.attachmentToRaw(attachment)),
1186
- flags: options.flags,
1304
+ attachments: options.attachments?.map((attachment) => ({
1305
+ id: attachment.id,
1306
+ filename: attachment.filename,
1307
+ title: attachment.title,
1308
+ description: attachment.description,
1309
+ content_type: attachment.contentType,
1310
+ size: attachment.size,
1311
+ url: attachment.url,
1312
+ proxy_url: attachment.proxyURL,
1313
+ height: attachment.height,
1314
+ width: attachment.width,
1315
+ ephemeral: attachment.ephemeral,
1316
+ duration_secs: attachment.durationSecs,
1317
+ waveform: attachment.waveform,
1318
+ flags: attachment.flags,
1319
+ })),
1187
1320
  },
1188
1321
  files: options.files,
1189
1322
  query: {
@@ -1215,8 +1348,22 @@ class Client extends node_events_1.default {
1215
1348
  ? transformers_1.Channels.componentsToRaw(options.components)
1216
1349
  : null
1217
1350
  : undefined,
1218
- attachments: options.attachments?.map((attachment) => transformers_1.Channels.attachmentToRaw(attachment)),
1219
- flags: options.flags,
1351
+ attachments: options.attachments?.map((attachment) => ({
1352
+ id: attachment.id,
1353
+ filename: attachment.filename,
1354
+ title: attachment.title,
1355
+ description: attachment.description,
1356
+ content_type: attachment.contentType,
1357
+ size: attachment.size,
1358
+ url: attachment.url,
1359
+ proxy_url: attachment.proxyURL,
1360
+ height: attachment.height,
1361
+ width: attachment.width,
1362
+ ephemeral: attachment.ephemeral,
1363
+ duration_secs: attachment.durationSecs,
1364
+ waveform: attachment.waveform,
1365
+ flags: attachment.flags,
1366
+ })),
1220
1367
  },
1221
1368
  files: options.files,
1222
1369
  query: {
@@ -1231,7 +1378,6 @@ class Client extends node_events_1.default {
1231
1378
  json: {
1232
1379
  channel_id: options.channelID,
1233
1380
  suppress: options.suppress,
1234
- requestToSpeakTimestamp: options.requestToSpeakTimestamp,
1235
1381
  },
1236
1382
  });
1237
1383
  }
@@ -1270,8 +1416,22 @@ class Client extends node_events_1.default {
1270
1416
  ? transformers_1.Channels.componentsToRaw(options.components)
1271
1417
  : null
1272
1418
  : undefined,
1273
- attachments: options.attachments?.map((attachment) => transformers_1.Channels.attachmentToRaw(attachment)),
1274
- flags: options.flags,
1419
+ attachments: options.attachments?.map((attachment) => ({
1420
+ id: attachment.id,
1421
+ filename: attachment.filename,
1422
+ title: attachment.title,
1423
+ description: attachment.description,
1424
+ content_type: attachment.contentType,
1425
+ size: attachment.size,
1426
+ url: attachment.url,
1427
+ proxy_url: attachment.proxyURL,
1428
+ height: attachment.height,
1429
+ width: attachment.width,
1430
+ ephemeral: attachment.ephemeral,
1431
+ duration_secs: attachment.durationSecs,
1432
+ waveform: attachment.waveform,
1433
+ flags: attachment.flags,
1434
+ })),
1275
1435
  },
1276
1436
  files: options.files,
1277
1437
  query: {
@@ -1423,14 +1583,7 @@ class Client extends node_events_1.default {
1423
1583
  /** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
1424
1584
  async getApplicationRoleConnectionMetadataRecords(applicationID) {
1425
1585
  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
- }));
1586
+ return response.map((applicationRoleConnectionMetadata) => transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(applicationRoleConnectionMetadata));
1434
1587
  }
1435
1588
  /** https://discord.com/developers/docs/resources/channel#get-channel */
1436
1589
  async getChannel(channelID) {
@@ -1463,14 +1616,7 @@ class Client extends node_events_1.default {
1463
1616
  return {
1464
1617
  platformName: response.platform_name,
1465
1618
  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
- },
1619
+ metadata: transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(response.metadata),
1474
1620
  };
1475
1621
  }
1476
1622
  /** https://discord.com/developers/docs/resources/user#get-current-user-guild-member */
@@ -1530,7 +1676,7 @@ class Client extends node_events_1.default {
1530
1676
  /** https://discord.com/developers/docs/interactions/application-commands#get-global-application-command */
1531
1677
  async getGlobalApplicationCommand(applicationID, commandID) {
1532
1678
  const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommand(applicationID, commandID));
1533
- return transformers_1.Applications.applicationCommandFromRaw(response);
1679
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
1534
1680
  }
1535
1681
  /** https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands */
1536
1682
  async getGlobalApplicationCommands(applicationID, options) {
@@ -1539,7 +1685,7 @@ class Client extends node_events_1.default {
1539
1685
  with_localizations: options.withLocalizations,
1540
1686
  },
1541
1687
  });
1542
- return response.map((applicationCommand) => transformers_1.Applications.applicationCommandFromRaw(applicationCommand));
1688
+ return response.map((applicationCommand) => transformers_1.ApplicationCommands.applicationCommandFromRaw(applicationCommand));
1543
1689
  }
1544
1690
  /** https://discord.com/developers/docs/resources/guild#get-guild */
1545
1691
  async getGuild(guildID, options) {
@@ -1560,12 +1706,21 @@ class Client extends node_events_1.default {
1560
1706
  with_counts: options?.withCounts,
1561
1707
  },
1562
1708
  });
1563
- return response.map((guild) => transformers_1.Guilds.guildFromRaw(guild));
1709
+ return response.map((guild) => ({
1710
+ id: guild.id,
1711
+ name: guild.name,
1712
+ icon: guild.icon,
1713
+ owner: guild.owner,
1714
+ permissions: guild.permissions,
1715
+ features: guild.features,
1716
+ approximate_member_count: guild.approximate_member_count,
1717
+ approximate_presence_count: guild.approximate_presence_count,
1718
+ }));
1564
1719
  }
1565
1720
  /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
1566
1721
  async getGuildApplicationCommand(applicationID, guildID, commandID) {
1567
1722
  const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationGuildCommand(applicationID, guildID, commandID));
1568
- return transformers_1.Applications.applicationCommandFromRaw(response);
1723
+ return transformers_1.ApplicationCommands.applicationCommandFromRaw(response);
1569
1724
  }
1570
1725
  /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
1571
1726
  async getGuildApplicationCommands(applicationID, guildID, options) {
@@ -1574,7 +1729,7 @@ class Client extends node_events_1.default {
1574
1729
  with_localizations: options?.withLocalizations,
1575
1730
  },
1576
1731
  });
1577
- return response.map((applicationCommand) => transformers_1.Applications.applicationCommandFromRaw(applicationCommand));
1732
+ return response.map((applicationCommand) => transformers_1.ApplicationCommands.applicationCommandFromRaw(applicationCommand));
1578
1733
  }
1579
1734
  /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
1580
1735
  async getGuildApplicationCommandPermissions(applicationID, guildID) {
@@ -2066,14 +2221,7 @@ class Client extends node_events_1.default {
2066
2221
  /** https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records */
2067
2222
  async updateApplicationRoleConnectionMetadataRecords(applicationID) {
2068
2223
  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
- }));
2224
+ return response.map((applicationRoleConnectionMetadata) => transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(applicationRoleConnectionMetadata));
2077
2225
  }
2078
2226
  /** https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection */
2079
2227
  async updateCurrentApplicationRoleConnection(applicationID, options) {
@@ -2081,20 +2229,15 @@ class Client extends node_events_1.default {
2081
2229
  json: {
2082
2230
  platform_name: options.platformName,
2083
2231
  platform_username: options.platformUsername,
2084
- metadata: options.metadata,
2232
+ metadata: options.metadata !== undefined
2233
+ ? transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataToRaw(options.metadata)
2234
+ : undefined,
2085
2235
  },
2086
2236
  });
2087
2237
  return {
2088
2238
  platformName: response.platform_name,
2089
2239
  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
- },
2240
+ metadata: transformers_1.ApplicationRoleConnectionMetadatas.applicationRoleConnectionMetadataFromRaw(response.metadata),
2098
2241
  };
2099
2242
  }
2100
2243
  /** https://discord.com/developers/docs/resources/channel#unpin-message */
@@ -500,9 +500,9 @@ class Shard {
500
500
  this.identify({
501
501
  token: this.client.token,
502
502
  properties: {
503
- os: process.platform,
504
- browser: pkg.name,
505
- device: pkg.name,
503
+ os: this.client.properties?.os ?? process.platform,
504
+ browser: this.client.properties?.browser ?? pkg.name,
505
+ device: this.client.properties?.device ?? pkg.name,
506
506
  },
507
507
  compress: this.client.compress,
508
508
  largeThreshold: this.client.largeThreshold,
@@ -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
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplicationCommands = void 0;
4
+ class ApplicationCommands {
5
+ static applicationCommandFromRaw(command) {
6
+ return {
7
+ id: command.id,
8
+ type: command.type,
9
+ applicationID: command.application_id,
10
+ guildID: command.guild_id,
11
+ name: command.name,
12
+ nameLocalizations: command.name_localizations,
13
+ description: command.description,
14
+ descriptionLocalizations: command.description_localizations,
15
+ options: command.options?.map((option) => this.optionFromRaw(option)),
16
+ defaultMemberPermissions: command.default_member_permissions,
17
+ dmPermission: command.dm_permission,
18
+ defaultPermission: command.default_permission,
19
+ integrationTypes: command.integration_types,
20
+ contexts: command.contexts,
21
+ nsfw: command.nsfw,
22
+ version: command.version,
23
+ };
24
+ }
25
+ static applicationCommandToRaw(command) {
26
+ return {
27
+ id: command.id,
28
+ type: command.type,
29
+ application_id: command.applicationID,
30
+ guild_id: command.guildID,
31
+ name: command.name,
32
+ name_localizations: command.nameLocalizations,
33
+ description: command.description,
34
+ description_localizations: command.descriptionLocalizations,
35
+ options: command.options?.map((option) => this.optionToRaw(option)),
36
+ default_member_permissions: command.defaultMemberPermissions,
37
+ dm_permission: command.dmPermission,
38
+ default_permission: command.defaultPermission,
39
+ integration_types: command.integrationTypes,
40
+ contexts: command.contexts,
41
+ nsfw: command.nsfw,
42
+ version: command.version,
43
+ };
44
+ }
45
+ static optionToRaw(option) {
46
+ return {
47
+ type: option.type,
48
+ name: option.name,
49
+ name_localizations: option.nameLocalizations,
50
+ description: option.description,
51
+ description_localizations: option.descriptionLocalizations,
52
+ required: option.required,
53
+ choices: option.choices?.map((choice) => ({
54
+ name: choice.name,
55
+ name_localizations: choice.nameLocalizations,
56
+ value: choice.value,
57
+ })),
58
+ options: option.options?.map((o) => this.optionFromRaw(o)),
59
+ channel_types: option.channelTypes,
60
+ min_value: option.minValue,
61
+ max_value: option.maxValue,
62
+ min_length: option.minLength,
63
+ max_length: option.maxLength,
64
+ autocomplete: option.autocomplete,
65
+ };
66
+ }
67
+ static optionFromRaw(option) {
68
+ return {
69
+ type: option.type,
70
+ name: option.name,
71
+ nameLocalizations: option.name_localizations,
72
+ description: option.description,
73
+ descriptionLocalizations: option.description_localizations,
74
+ required: option.required,
75
+ choices: option.choices?.map((choice) => ({
76
+ name: choice.name,
77
+ nameLocalizations: choice.name_localizations,
78
+ value: choice.value,
79
+ })),
80
+ options: option.options?.map((o) => this.optionFromRaw(o)),
81
+ channelTypes: option.channel_types,
82
+ minValue: option.min_value,
83
+ maxValue: option.max_value,
84
+ minLength: option.min_length,
85
+ maxLength: option.max_length,
86
+ autocomplete: option.autocomplete,
87
+ };
88
+ }
89
+ }
90
+ exports.ApplicationCommands = ApplicationCommands;