disgroove 2.2.0-dev.15819eb → 2.2.0-dev.301452e

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.
@@ -1,46 +1,2154 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Util = void 0;
4
+ const constants_1 = require("../constants");
4
5
  class Util {
5
- toCamelCase(obj) {
6
- if (obj !== null && typeof obj === "object") {
7
- if (Array.isArray(obj)) {
8
- return obj.map((item) => this.toCamelCase(item));
9
- }
10
- else {
11
- const newObj = {};
12
- for (const key in obj) {
13
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
14
- const newKey = key.replace(/_([a-z])/g, (match, letter) => letter.toUpperCase());
15
- newObj[newKey] = this.toCamelCase(obj[key]);
6
+ auditLogFromRaw(auditLog) {
7
+ return {
8
+ applicationCommands: auditLog.application_commands.map((applicationCommand) => this.applicationCommandFromRaw(applicationCommand)),
9
+ auditLogEntries: auditLog.audit_log_entries.map((auditLogEntry) => this.auditLogEntryFromRaw(auditLogEntry)),
10
+ autoModerationRules: auditLog.auto_moderation_rules.map((autoModerationRule) => this.autoModerationRuleFromRaw(autoModerationRule)),
11
+ guildScheduledEvents: auditLog.guild_scheduled_events.map((guildScheduledEvent) => this.guildScheduledEventFromRaw(guildScheduledEvent)),
12
+ integrations: auditLog.integrations.map((integration) => this.integrationFromRaw(integration)),
13
+ threads: auditLog.threads.map((thread) => this.channelFromRaw(thread)),
14
+ users: auditLog.users.map((user) => this.userFromRaw(user)),
15
+ webhooks: auditLog.webhooks.map((webhook) => this.webhookFromRaw(webhook)),
16
+ };
17
+ }
18
+ auditLogToRaw(auditLog) {
19
+ return {
20
+ application_commands: auditLog.applicationCommands.map((applicationCommand) => this.applicationCommandToRaw(applicationCommand)),
21
+ audit_log_entries: auditLog.auditLogEntries.map((auditLogEntry) => this.auditLogEntryToRaw(auditLogEntry)),
22
+ auto_moderation_rules: auditLog.autoModerationRules.map((autoModerationRule) => this.autoModerationRuleToRaw(autoModerationRule)),
23
+ guild_scheduled_events: auditLog.guildScheduledEvents.map((guildScheduledEvent) => this.guildScheduledEventToRaw(guildScheduledEvent)),
24
+ integrations: auditLog.integrations.map((integration) => this.integrationToRaw(integration)),
25
+ threads: auditLog.threads.map((thread) => this.channelToRaw(thread)),
26
+ users: auditLog.users.map((user) => this.userToRaw(user)),
27
+ webhooks: auditLog.webhooks.map((webhook) => this.webhookToRaw(webhook)),
28
+ };
29
+ }
30
+ auditLogEntryFromRaw(auditLogEntry) {
31
+ return {
32
+ targetId: auditLogEntry.target_id,
33
+ changes: auditLogEntry.changes?.map((auditLogChange) => ({
34
+ newValue: auditLogChange.new_value,
35
+ oldValue: auditLogChange.old_value,
36
+ key: auditLogChange.key,
37
+ })),
38
+ userId: auditLogEntry.user_id,
39
+ id: auditLogEntry.id,
40
+ actionType: auditLogEntry.action_type,
41
+ options: auditLogEntry.options !== undefined
42
+ ? {
43
+ applicationId: auditLogEntry.options.application_id,
44
+ autoModerationRuleName: auditLogEntry.options.auto_moderation_rule_name,
45
+ autoModerationRuleTriggerType: auditLogEntry.options.auto_moderation_rule_trigger_type,
46
+ channelId: auditLogEntry.options.channel_id,
47
+ count: auditLogEntry.options.count,
48
+ deleteMemberDays: auditLogEntry.options.delete_member_days,
49
+ id: auditLogEntry.options.id,
50
+ membersRemoved: auditLogEntry.options.members_removed,
51
+ messageId: auditLogEntry.options.message_id,
52
+ roleName: auditLogEntry.options.role_name,
53
+ type: auditLogEntry.options.type,
54
+ integrationType: auditLogEntry.options.integration_type,
55
+ }
56
+ : undefined,
57
+ reason: auditLogEntry.reason,
58
+ };
59
+ }
60
+ auditLogEntryToRaw(auditLogEntry) {
61
+ return {
62
+ target_id: auditLogEntry.targetId,
63
+ changes: auditLogEntry.changes?.map((auditLogChange) => ({
64
+ new_value: auditLogChange.newValue,
65
+ old_value: auditLogChange.oldValue,
66
+ key: auditLogChange.key,
67
+ })),
68
+ user_id: auditLogEntry.userId,
69
+ id: auditLogEntry.id,
70
+ action_type: auditLogEntry.actionType,
71
+ options: auditLogEntry.options !== undefined
72
+ ? {
73
+ application_id: auditLogEntry.options.applicationId,
74
+ auto_moderation_rule_name: auditLogEntry.options.autoModerationRuleName,
75
+ auto_moderation_rule_trigger_type: auditLogEntry.options.autoModerationRuleTriggerType,
76
+ channel_id: auditLogEntry.options.channelId,
77
+ count: auditLogEntry.options.count,
78
+ delete_member_days: auditLogEntry.options.deleteMemberDays,
79
+ id: auditLogEntry.options.id,
80
+ members_removed: auditLogEntry.options.membersRemoved,
81
+ message_id: auditLogEntry.options.messageId,
82
+ role_name: auditLogEntry.options.roleName,
83
+ type: auditLogEntry.options.type,
84
+ integration_type: auditLogEntry.options.integrationType,
85
+ }
86
+ : undefined,
87
+ reason: auditLogEntry.reason,
88
+ };
89
+ }
90
+ autoModerationRuleFromRaw(autoModerationRule) {
91
+ return {
92
+ id: autoModerationRule.id,
93
+ guildId: autoModerationRule.guild_id,
94
+ name: autoModerationRule.name,
95
+ creatorId: autoModerationRule.creator_id,
96
+ eventType: autoModerationRule.event_type,
97
+ triggerType: autoModerationRule.trigger_type,
98
+ triggerMetadata: {
99
+ keywordFilter: autoModerationRule.trigger_metadata.keyword_filter,
100
+ regexPatterns: autoModerationRule.trigger_metadata.regex_patterns,
101
+ presets: autoModerationRule.trigger_metadata.presets,
102
+ allowList: autoModerationRule.trigger_metadata.allow_list,
103
+ mentionTotalLimit: autoModerationRule.trigger_metadata.mention_total_limit,
104
+ mentionRaidProtection: autoModerationRule.trigger_metadata.mention_raid_protection,
105
+ },
106
+ actions: autoModerationRule.actions.map((action) => ({
107
+ type: action.type,
108
+ metadata: {
109
+ channelId: action.metadata.channel_id,
110
+ durationSeconds: action.metadata.duration_seconds,
111
+ customMessage: action.metadata.custom_message,
112
+ },
113
+ })),
114
+ enabled: autoModerationRule.enabled,
115
+ exemptRoles: autoModerationRule.exempt_roles,
116
+ exemptChannels: autoModerationRule.exempt_channels,
117
+ };
118
+ }
119
+ autoModerationRuleToRaw(autoModerationRule) {
120
+ return {
121
+ id: autoModerationRule.id,
122
+ guild_id: autoModerationRule.guildId,
123
+ name: autoModerationRule.name,
124
+ creator_id: autoModerationRule.creatorId,
125
+ event_type: autoModerationRule.eventType,
126
+ trigger_type: autoModerationRule.triggerType,
127
+ trigger_metadata: {
128
+ keyword_filter: autoModerationRule.triggerMetadata.keywordFilter,
129
+ regex_patterns: autoModerationRule.triggerMetadata.regexPatterns,
130
+ presets: autoModerationRule.triggerMetadata.presets,
131
+ allow_list: autoModerationRule.triggerMetadata.allowList,
132
+ mention_total_limit: autoModerationRule.triggerMetadata.mentionTotalLimit,
133
+ mention_raid_protection: autoModerationRule.triggerMetadata.mentionRaidProtection,
134
+ },
135
+ actions: autoModerationRule.actions.map((action) => ({
136
+ type: action.type,
137
+ metadata: {
138
+ channel_id: action.metadata.channelId,
139
+ duration_seconds: action.metadata.durationSeconds,
140
+ custom_message: action.metadata.customMessage,
141
+ },
142
+ })),
143
+ enabled: autoModerationRule.enabled,
144
+ exempt_roles: autoModerationRule.exemptRoles,
145
+ exempt_channels: autoModerationRule.exemptChannels,
146
+ };
147
+ }
148
+ attachmentFromRaw(attachment) {
149
+ return {
150
+ id: attachment.id,
151
+ filename: attachment.filename,
152
+ description: attachment.description,
153
+ contentType: attachment.content_type,
154
+ size: attachment.size,
155
+ url: attachment.url,
156
+ proxyUrl: attachment.proxy_url,
157
+ height: attachment.height,
158
+ width: attachment.width,
159
+ ephemeral: attachment.ephemeral,
160
+ durationSecs: attachment.duration_secs,
161
+ waveform: attachment.waveform,
162
+ flags: attachment.flags,
163
+ };
164
+ }
165
+ attachmentToRaw(attachment) {
166
+ return {
167
+ id: attachment.id,
168
+ filename: attachment.filename,
169
+ description: attachment.description,
170
+ content_type: attachment.contentType,
171
+ size: attachment.size,
172
+ url: attachment.url,
173
+ proxy_url: attachment.proxyUrl,
174
+ height: attachment.height,
175
+ width: attachment.width,
176
+ ephemeral: attachment.ephemeral,
177
+ duration_secs: attachment.durationSecs,
178
+ waveform: attachment.waveform,
179
+ flags: attachment.flags,
180
+ };
181
+ }
182
+ applicationFromRaw(application) {
183
+ return {
184
+ id: application.id,
185
+ name: application.name,
186
+ icon: application.icon,
187
+ description: application.description,
188
+ rpcOrigins: application.rpc_origins,
189
+ botPublic: application.bot_public,
190
+ botRequireCodeGrant: application.bot_require_code_grant,
191
+ termsOfServiceUrl: application.terms_of_service_url,
192
+ privacyPolicyUrl: application.privacy_policy_url,
193
+ owner: application.owner !== undefined
194
+ ? this.userFromRaw(application.owner)
195
+ : undefined,
196
+ verifyKey: application.verify_key,
197
+ team: application.team !== null ? this.teamFromRaw(application.team) : null,
198
+ guildId: application.guild_id,
199
+ guild: application.guild !== undefined
200
+ ? this.guildFromRaw(application.guild)
201
+ : undefined,
202
+ primarySkuId: application.primary_sku_id,
203
+ slug: application.slug,
204
+ coverImage: application.cover_image,
205
+ flags: application.flags,
206
+ approximateGuildCount: application.approximate_guild_count,
207
+ redirectURIs: application.redirect_uris,
208
+ interactionsEndpointUrl: application.interactions_endpoint_url,
209
+ roleConnectionsVerificationUrl: application.role_connections_verification_url,
210
+ tags: application.tags,
211
+ installParams: application.install_params,
212
+ integrationTypesConfig: application.integration_types_config !== undefined
213
+ ? {
214
+ "0": {
215
+ oauth2InstallParams: application.integration_types_config?.[0]
216
+ .oauth2_install_params,
217
+ },
218
+ "1": {
219
+ oauth2InstallParams: application.integration_types_config?.[1]
220
+ .oauth2_install_params,
221
+ },
222
+ }
223
+ : undefined,
224
+ customInstallUrl: application.custom_install_url,
225
+ };
226
+ }
227
+ applicationToRaw(application) {
228
+ return {
229
+ id: application.id,
230
+ name: application.name,
231
+ icon: application.icon,
232
+ description: application.description,
233
+ rpc_origins: application.rpcOrigins,
234
+ bot_public: application.botPublic,
235
+ bot_require_code_grant: application.botRequireCodeGrant,
236
+ terms_of_service_url: application.termsOfServiceUrl,
237
+ privacy_policy_url: application.privacyPolicyUrl,
238
+ owner: application.owner !== undefined
239
+ ? this.userToRaw(application.owner)
240
+ : undefined,
241
+ verify_key: application.verifyKey,
242
+ team: application.team !== null ? this.teamToRaw(application.team) : null,
243
+ guild_id: application.guildId,
244
+ guild: application.guild !== undefined
245
+ ? this.guildToRaw(application.guild)
246
+ : undefined,
247
+ primary_sku_id: application.primarySkuId,
248
+ slug: application.slug,
249
+ cover_image: application.coverImage,
250
+ flags: application.flags,
251
+ approximate_guild_count: application.approximateGuildCount,
252
+ redirect_uris: application.redirectURIs,
253
+ interactions_endpoint_url: application.interactionsEndpointUrl,
254
+ role_connections_verification_url: application.roleConnectionsVerificationUrl,
255
+ tags: application.tags,
256
+ install_params: application.installParams,
257
+ integration_types_config: application.integrationTypesConfig !== undefined
258
+ ? {
259
+ "0": {
260
+ oauth2_install_params: application.integrationTypesConfig?.[0].oauth2InstallParams,
261
+ },
262
+ "1": {
263
+ oauth2_install_params: application.integrationTypesConfig?.[1].oauth2InstallParams,
264
+ },
265
+ }
266
+ : undefined,
267
+ custom_install_url: application.customInstallUrl,
268
+ };
269
+ }
270
+ applicationCommandFromRaw(applicationCommand) {
271
+ return {
272
+ id: applicationCommand.id,
273
+ type: applicationCommand.type,
274
+ applicationId: applicationCommand.application_id,
275
+ guildId: applicationCommand.guild_id,
276
+ name: applicationCommand.name,
277
+ nameLocalizations: applicationCommand.name_localizations,
278
+ description: applicationCommand.description,
279
+ descriptionLocalizations: applicationCommand.description_localizations,
280
+ options: applicationCommand.options?.map((option) => ({
281
+ type: option.type,
282
+ name: option.name,
283
+ name_localizations: option.name_localizations,
284
+ description: option.description,
285
+ description_localizations: option.description_localizations,
286
+ required: option.required,
287
+ choices: option.choices?.map((choice) => ({
288
+ name: choice.name,
289
+ name_localizations: choice.name_localizations,
290
+ value: choice.value,
291
+ })),
292
+ options: option.options?.map((o) => ({
293
+ type: o.type,
294
+ name: o.name,
295
+ name_localizations: o.name_localizations,
296
+ description: o.description,
297
+ description_localizations: o.description_localizations,
298
+ required: o.required,
299
+ choices: o.choices?.map((choice) => ({
300
+ name: choice.name,
301
+ name_localizations: choice.name_localizations,
302
+ value: choice.value,
303
+ })),
304
+ channel_types: o.channel_types,
305
+ min_value: o.min_value,
306
+ max_value: o.max_value,
307
+ min_length: o.min_length,
308
+ max_length: o.max_length,
309
+ autocomplete: o.autocomplete,
310
+ })),
311
+ channel_types: option.channel_types,
312
+ min_value: option.min_value,
313
+ max_value: option.max_value,
314
+ min_length: option.min_length,
315
+ max_length: option.max_length,
316
+ autocomplete: option.autocomplete,
317
+ })),
318
+ defaultMemberPermissions: applicationCommand.default_member_permissions,
319
+ dmPermission: applicationCommand.dm_permission,
320
+ defaultPermission: applicationCommand.default_permission,
321
+ nsfw: applicationCommand.nsfw,
322
+ version: applicationCommand.version,
323
+ };
324
+ }
325
+ applicationCommandToRaw(applicationCommand) {
326
+ return {
327
+ id: applicationCommand.id,
328
+ type: applicationCommand.type,
329
+ application_id: applicationCommand.applicationId,
330
+ guild_id: applicationCommand.guildId,
331
+ name: applicationCommand.name,
332
+ name_localizations: applicationCommand.nameLocalizations,
333
+ description: applicationCommand.description,
334
+ description_localizations: applicationCommand.descriptionLocalizations,
335
+ options: applicationCommand.options?.map((option) => ({
336
+ type: option.type,
337
+ name: option.name,
338
+ name_localizations: option.nameLocalizations,
339
+ description: option.description,
340
+ description_localizations: option.descriptionLocalizations,
341
+ required: option.required,
342
+ choices: option.choices?.map((choice) => ({
343
+ name: choice.name,
344
+ name_localizations: choice.nameLocalizations,
345
+ value: choice.value,
346
+ })),
347
+ options: option.options?.map((o) => ({
348
+ type: o.type,
349
+ name: o.name,
350
+ name_localizations: o.nameLocalizations,
351
+ description: o.description,
352
+ description_localizations: o.descriptionLocalizations,
353
+ required: o.required,
354
+ choices: o.choices?.map((choice) => ({
355
+ name: choice.name,
356
+ name_localizations: choice.nameLocalizations,
357
+ value: choice.value,
358
+ })),
359
+ channel_types: o.channelTypes,
360
+ min_value: o.minValue,
361
+ max_value: o.maxValue,
362
+ min_length: o.minLength,
363
+ max_length: o.maxLength,
364
+ autocomplete: o.autocomplete,
365
+ })),
366
+ channel_types: option.channelTypes,
367
+ min_value: option.minValue,
368
+ max_value: option.maxValue,
369
+ min_length: option.minLength,
370
+ max_length: option.maxLength,
371
+ autocomplete: option.autocomplete,
372
+ })),
373
+ default_member_permissions: applicationCommand.defaultMemberPermissions,
374
+ dm_permission: applicationCommand.dmPermission,
375
+ default_permission: applicationCommand.defaultPermission,
376
+ nsfw: applicationCommand.nsfw,
377
+ version: applicationCommand.version,
378
+ };
379
+ }
380
+ channelFromRaw(channel) {
381
+ return {
382
+ id: channel.id,
383
+ type: channel.type,
384
+ guildId: channel.guild_id,
385
+ position: channel.position,
386
+ permissionOverwrites: channel.permission_overwrites?.map((overwrite) => ({
387
+ id: overwrite.id,
388
+ type: overwrite.type,
389
+ allow: overwrite.allow,
390
+ deny: overwrite.deny,
391
+ })),
392
+ name: channel.name,
393
+ topic: channel.topic,
394
+ nsfw: channel.nsfw,
395
+ lastMessageId: channel.last_message_id,
396
+ bitrate: channel.bitrate,
397
+ userLimit: channel.user_limit,
398
+ rateLimitPerUser: channel.rate_limit_per_user,
399
+ recipients: channel.recipients?.map((recipient) => this.userFromRaw(recipient)),
400
+ icon: channel.icon,
401
+ ownerId: channel.owner_id,
402
+ applicationId: channel.application_id,
403
+ managed: channel.managed,
404
+ parentId: channel.parent_id,
405
+ lastPinTimestamp: channel.last_pin_timestamp,
406
+ rtcRegion: channel.rtc_region,
407
+ videoQualityMode: channel.video_quality_mode,
408
+ messageCount: channel.member_count,
409
+ memberCount: channel.member_count,
410
+ threadMetadata: channel.thread_metadata !== undefined
411
+ ? {
412
+ archived: channel.thread_metadata?.archived,
413
+ autoArchiveDuration: channel.thread_metadata?.auto_archive_duration,
414
+ archiveTimestamp: channel.thread_metadata?.archive_timestamp,
415
+ locked: channel.thread_metadata?.locked,
416
+ invitable: channel.thread_metadata?.invitable,
417
+ createTimestamp: channel.thread_metadata?.create_timestamp,
418
+ }
419
+ : undefined,
420
+ member: channel.member !== undefined
421
+ ? {
422
+ id: channel.member.id,
423
+ userId: channel.member.user_id,
424
+ joinTimestamp: channel.member.join_timestamp,
425
+ flags: channel.member.flags,
426
+ member: channel.member.member !== undefined
427
+ ? {
428
+ user: channel.member.member.user !== undefined
429
+ ? this.userFromRaw(channel.member.member.user)
430
+ : undefined,
431
+ nick: channel.member.member.nick,
432
+ avatar: channel.member.member.avatar,
433
+ roles: channel.member.member.roles,
434
+ joinedAt: channel.member.member.joined_at,
435
+ premiumSince: channel.member.member.premium_since,
436
+ deaf: channel.member.member.deaf,
437
+ mute: channel.member.member.mute,
438
+ flags: channel.member.member.flags,
439
+ pending: channel.member.member.pending,
440
+ permissions: channel.member.member.permissions,
441
+ communicationDisabledUntil: channel.member.member.communication_disabled_until,
442
+ }
443
+ : undefined,
444
+ }
445
+ : undefined,
446
+ defaultAutoArchiveDuration: channel.default_auto_archive_duration,
447
+ permissions: channel.permissions,
448
+ flags: channel.flags,
449
+ totalMessageSent: channel.total_message_sent,
450
+ availableTags: channel.available_tags?.map((availableTag) => ({
451
+ id: availableTag.id,
452
+ name: availableTag.name,
453
+ moderated: availableTag.moderated,
454
+ emojiId: availableTag.emoji_id,
455
+ emojiName: availableTag.emoji_name,
456
+ })),
457
+ appliedTags: channel.applied_tags,
458
+ defaultReactionEmoji: channel.default_reaction_emoji !== undefined
459
+ ? channel.default_reaction_emoji !== null
460
+ ? {
461
+ emojiId: channel.default_reaction_emoji.emoji_id,
462
+ emojiName: channel.default_reaction_emoji.emoji_name,
463
+ }
464
+ : null
465
+ : undefined,
466
+ defaultThreadRateLimitPerUser: channel.default_thread_rate_limit_per_user,
467
+ defaultSortOrder: channel.default_sort_order,
468
+ defaultForumLayout: channel.default_forum_layout,
469
+ };
470
+ }
471
+ channelToRaw(channel) {
472
+ return {
473
+ id: channel.id,
474
+ type: channel.type,
475
+ guild_id: channel.guildId,
476
+ position: channel.position,
477
+ permission_overwrites: channel.permissionOverwrites?.map((overwrite) => ({
478
+ id: overwrite.id,
479
+ type: overwrite.type,
480
+ allow: overwrite.allow,
481
+ deny: overwrite.deny,
482
+ })),
483
+ name: channel.name,
484
+ topic: channel.topic,
485
+ nsfw: channel.nsfw,
486
+ last_message_id: channel.lastMessageId,
487
+ bitrate: channel.bitrate,
488
+ user_limit: channel.userLimit,
489
+ rate_limit_per_user: channel.rateLimitPerUser,
490
+ recipients: channel.recipients?.map((recipient) => this.userToRaw(recipient)),
491
+ icon: channel.icon,
492
+ owner_id: channel.ownerId,
493
+ application_id: channel.applicationId,
494
+ managed: channel.managed,
495
+ parent_id: channel.parentId,
496
+ last_pin_timestamp: channel.lastPinTimestamp,
497
+ rtc_region: channel.rtcRegion,
498
+ video_quality_mode: channel.videoQualityMode,
499
+ message_count: channel.messageCount,
500
+ member_count: channel.memberCount,
501
+ thread_metadata: channel.threadMetadata !== undefined
502
+ ? {
503
+ archived: channel.threadMetadata?.archived,
504
+ auto_archive_duration: channel.threadMetadata?.autoArchiveDuration,
505
+ archive_timestamp: channel.threadMetadata?.archiveTimestamp,
506
+ locked: channel.threadMetadata?.locked,
507
+ invitable: channel.threadMetadata?.invitable,
508
+ create_timestamp: channel.threadMetadata?.createTimestamp,
509
+ }
510
+ : undefined,
511
+ member: channel.member !== undefined
512
+ ? {
513
+ id: channel.member.id,
514
+ user_id: channel.member.userId,
515
+ join_timestamp: channel.member.joinTimestamp,
516
+ flags: channel.member.flags,
517
+ member: channel.member.member !== undefined
518
+ ? {
519
+ user: channel.member.member.user !== undefined
520
+ ? this.userToRaw(channel.member.member.user)
521
+ : undefined,
522
+ nick: channel.member.member.nick,
523
+ avatar: channel.member.member.avatar,
524
+ roles: channel.member.member.roles,
525
+ joined_at: channel.member.member.joinedAt,
526
+ premium_since: channel.member.member.premiumSince,
527
+ deaf: channel.member.member.deaf,
528
+ mute: channel.member.member.mute,
529
+ flags: channel.member.member.flags,
530
+ pending: channel.member.member.pending,
531
+ permissions: channel.member.member.permissions,
532
+ communication_disabled_until: channel.member.member.communicationDisabledUntil,
533
+ }
534
+ : undefined,
535
+ }
536
+ : undefined,
537
+ default_auto_archive_duration: channel.defaultAutoArchiveDuration,
538
+ permissions: channel.permissions,
539
+ flags: channel.flags,
540
+ total_message_sent: channel.totalMessageSent,
541
+ available_tags: channel.availableTags?.map((availableTag) => ({
542
+ id: availableTag.id,
543
+ name: availableTag.name,
544
+ moderated: availableTag.moderated,
545
+ emoji_id: availableTag.emojiId,
546
+ emoji_name: availableTag.emojiName,
547
+ })),
548
+ applied_tags: channel.appliedTags,
549
+ default_reaction_emoji: channel.defaultReactionEmoji !== undefined
550
+ ? channel.defaultReactionEmoji !== null
551
+ ? {
552
+ emoji_id: channel.defaultReactionEmoji.emojiId,
553
+ emoji_name: channel.defaultReactionEmoji.emojiName,
16
554
  }
555
+ : null
556
+ : undefined,
557
+ default_thread_rate_limit_per_user: channel.defaultThreadRateLimitPerUser,
558
+ default_sort_order: channel.defaultSortOrder,
559
+ default_forum_layout: channel.defaultForumLayout,
560
+ };
561
+ }
562
+ embedFromRaw(embed) {
563
+ return {
564
+ title: embed.title,
565
+ type: embed.type,
566
+ description: embed.description,
567
+ url: embed.url,
568
+ timestamp: embed.timestamp,
569
+ color: embed.color,
570
+ footer: embed.footer !== undefined
571
+ ? {
572
+ text: embed.footer.text,
573
+ iconUrl: embed.footer.icon_url,
574
+ proxyIconUrl: embed.footer.proxy_icon_url,
575
+ }
576
+ : undefined,
577
+ image: embed.image !== undefined
578
+ ? {
579
+ url: embed.image.url,
580
+ proxyUrl: embed.image.proxy_url,
581
+ height: embed.image.height,
582
+ width: embed.image.width,
17
583
  }
18
- return newObj;
584
+ : undefined,
585
+ thumbnail: embed.thumbnail !== undefined
586
+ ? {
587
+ url: embed.thumbnail.url,
588
+ proxyUrl: embed.thumbnail.proxy_url,
589
+ height: embed.thumbnail.height,
590
+ width: embed.thumbnail.width,
591
+ }
592
+ : undefined,
593
+ video: {
594
+ url: embed.video?.url,
595
+ proxyUrl: embed.video?.proxy_url,
596
+ height: embed.video?.height,
597
+ width: embed.video?.width,
598
+ },
599
+ provider: {
600
+ name: embed.provider?.name,
601
+ url: embed.provider?.url,
602
+ },
603
+ author: embed.author !== undefined
604
+ ? {
605
+ name: embed.author.name,
606
+ url: embed.author.url,
607
+ iconUrl: embed.author.icon_url,
608
+ proxyIconUrl: embed.author.proxy_icon_url,
609
+ }
610
+ : undefined,
611
+ fields: embed.fields?.map((field) => ({
612
+ name: field.name,
613
+ value: field.value,
614
+ inline: field.inline,
615
+ })),
616
+ };
617
+ }
618
+ embedToRaw(embed) {
619
+ return {
620
+ title: embed.title,
621
+ type: embed.type,
622
+ description: embed.description,
623
+ url: embed.url,
624
+ timestamp: embed.timestamp,
625
+ color: embed.color,
626
+ footer: embed.footer !== undefined
627
+ ? {
628
+ text: embed.footer.text,
629
+ icon_url: embed.footer.iconUrl,
630
+ proxy_icon_url: embed.footer.proxyIconUrl,
631
+ }
632
+ : undefined,
633
+ image: embed.image !== undefined
634
+ ? {
635
+ url: embed.image.url,
636
+ proxy_url: embed.image.proxyUrl,
637
+ height: embed.image.height,
638
+ width: embed.image.width,
639
+ }
640
+ : undefined,
641
+ thumbnail: embed.thumbnail !== undefined
642
+ ? {
643
+ url: embed.thumbnail.url,
644
+ proxy_url: embed.thumbnail.proxyUrl,
645
+ height: embed.thumbnail.height,
646
+ width: embed.thumbnail.width,
647
+ }
648
+ : undefined,
649
+ video: {
650
+ url: embed.video?.url,
651
+ proxy_url: embed.video?.proxyUrl,
652
+ height: embed.video?.height,
653
+ width: embed.video?.width,
654
+ },
655
+ provider: {
656
+ name: embed.provider?.name,
657
+ url: embed.provider?.url,
658
+ },
659
+ author: embed.author !== undefined
660
+ ? {
661
+ name: embed.author.name,
662
+ url: embed.author.url,
663
+ icon_url: embed.author.iconUrl,
664
+ proxy_icon_url: embed.author.proxyIconUrl,
665
+ }
666
+ : undefined,
667
+ fields: embed.fields?.map((field) => ({
668
+ name: field.name,
669
+ value: field.value,
670
+ inline: field.inline,
671
+ })),
672
+ };
673
+ }
674
+ emojiFromRaw(emoji) {
675
+ return {
676
+ id: emoji.id,
677
+ name: emoji.name,
678
+ roles: emoji.roles,
679
+ user: emoji.user !== undefined ? this.userFromRaw(emoji.user) : undefined,
680
+ requireColons: emoji.require_colons,
681
+ managed: emoji.managed,
682
+ animated: emoji.animated,
683
+ available: emoji.available,
684
+ };
685
+ }
686
+ emojiToRaw(emoji) {
687
+ return {
688
+ id: emoji.id,
689
+ name: emoji.name,
690
+ roles: emoji.roles,
691
+ user: emoji.user !== undefined ? this.userToRaw(emoji.user) : undefined,
692
+ require_colons: emoji.requireColons,
693
+ managed: emoji.managed,
694
+ animated: emoji.animated,
695
+ available: emoji.available,
696
+ };
697
+ }
698
+ entitlementFromRaw(entitlement) {
699
+ return {
700
+ id: entitlement.id,
701
+ skuId: entitlement.sku_id,
702
+ applicationId: entitlement.application_id,
703
+ userId: entitlement.user_id,
704
+ promotionId: entitlement.promotion_id,
705
+ type: entitlement.type,
706
+ deleted: entitlement.deleted,
707
+ giftCodeFlags: entitlement.gift_code_flags,
708
+ consumed: entitlement.consumed,
709
+ startsAt: entitlement.starts_at,
710
+ endsAt: entitlement.ends_at,
711
+ guildId: entitlement.guild_id,
712
+ subscriptionId: entitlement.subscription_id,
713
+ };
714
+ }
715
+ entitlementToRaw(entitlement) {
716
+ return {
717
+ id: entitlement.id,
718
+ sku_id: entitlement.skuId,
719
+ application_id: entitlement.applicationId,
720
+ user_id: entitlement.userId,
721
+ promotion_id: entitlement.promotionId,
722
+ type: entitlement.type,
723
+ deleted: entitlement.deleted,
724
+ gift_code_flags: entitlement.giftCodeFlags,
725
+ consumed: entitlement.consumed,
726
+ starts_at: entitlement.startsAt,
727
+ ends_at: entitlement.endsAt,
728
+ guild_id: entitlement.guildId,
729
+ subscription_id: entitlement.subscriptionId,
730
+ };
731
+ }
732
+ guildFromRaw(guild) {
733
+ return {
734
+ id: guild.id,
735
+ name: guild.name,
736
+ icon: guild.icon,
737
+ iconHash: guild.icon,
738
+ splash: guild.splash,
739
+ discoverySplash: guild.discovery_splash,
740
+ owner: guild.owner,
741
+ ownerId: guild.owner_id,
742
+ permissions: guild.permissions,
743
+ region: guild.region,
744
+ afkChannelId: guild.afk_channel_id,
745
+ afkTimeout: guild.afk_timeout,
746
+ widgetEnabled: guild.widget_enabled,
747
+ widgetChannelId: guild.widget_channel_id,
748
+ verificationLevel: guild.verification_level,
749
+ defaultMessageNotifications: guild.default_message_notifications,
750
+ explicitContentFilter: guild.explicit_content_filter,
751
+ roles: guild.roles.map((role) => this.roleFromRaw(role)),
752
+ emojis: guild.emojis.map((emoji) => this.emojiFromRaw(emoji)),
753
+ features: guild.features,
754
+ mfaLevel: guild.mfa_level,
755
+ applicationId: guild.application_id,
756
+ systemChannelId: guild.system_channel_id,
757
+ systemChannelFlags: guild.system_channel_flags,
758
+ rulesChannelId: guild.rules_channel_id,
759
+ maxPresences: guild.max_presences,
760
+ maxMembers: guild.max_members,
761
+ vanityUrlCode: guild.vanity_url_code,
762
+ description: guild.description,
763
+ banner: guild.banner,
764
+ premiumTier: guild.premium_tier,
765
+ premiumSubscriptionCount: guild.premium_subscription_count,
766
+ preferredLocale: guild.preferred_locale,
767
+ publicUpdatesChannelId: guild.public_updates_channel_id,
768
+ maxVideoChannelUsers: guild.max_video_channel_users,
769
+ maxStageVideoChannelUsers: guild.max_stage_video_channel_users,
770
+ approximateMemberCount: guild.approximate_member_count,
771
+ approximatePresenceCount: guild.approximate_presence_count,
772
+ welcomeScreen: guild.welcome_screen !== undefined
773
+ ? {
774
+ description: guild.welcome_screen.description,
775
+ welcomeChannels: guild.welcome_screen.welcome_channels.map((welcomeScreenChannel) => ({
776
+ channelId: welcomeScreenChannel.channel_id,
777
+ description: welcomeScreenChannel.description,
778
+ emojiId: welcomeScreenChannel.emoji_id,
779
+ emojiName: welcomeScreenChannel.emoji_name,
780
+ })),
781
+ }
782
+ : undefined,
783
+ nsfwLevel: guild.nsfw_level,
784
+ stickers: guild.stickers?.map((sticker) => this.stickerFromRaw(sticker)),
785
+ premiumProgressBarEnabled: guild.premium_progress_bar_enabled,
786
+ safetyAlertsChannelId: guild.safety_alerts_channel_id,
787
+ };
788
+ }
789
+ guildToRaw(guild) {
790
+ return {
791
+ id: guild.id,
792
+ name: guild.name,
793
+ icon: guild.icon,
794
+ icon_hash: guild.icon,
795
+ splash: guild.splash,
796
+ discovery_splash: guild.discoverySplash,
797
+ owner: guild.owner,
798
+ owner_id: guild.ownerId,
799
+ permissions: guild.permissions,
800
+ region: guild.region,
801
+ afk_channel_id: guild.afkChannelId,
802
+ afk_timeout: guild.afkTimeout,
803
+ widget_enabled: guild.widgetEnabled,
804
+ widget_channel_id: guild.widgetChannelId,
805
+ verification_level: guild.verificationLevel,
806
+ default_message_notifications: guild.defaultMessageNotifications,
807
+ explicit_content_filter: guild.explicitContentFilter,
808
+ roles: guild.roles.map((role) => this.roleToRaw(role)),
809
+ emojis: guild.emojis.map((emoji) => this.emojiToRaw(emoji)),
810
+ features: guild.features,
811
+ mfa_level: guild.mfaLevel,
812
+ application_id: guild.applicationId,
813
+ system_channel_id: guild.systemChannelId,
814
+ system_channel_flags: guild.systemChannelFlags,
815
+ rules_channel_id: guild.rulesChannelId,
816
+ max_presences: guild.maxPresences,
817
+ max_members: guild.maxMembers,
818
+ vanity_url_code: guild.vanityUrlCode,
819
+ description: guild.description,
820
+ banner: guild.banner,
821
+ premium_tier: guild.premiumTier,
822
+ premium_subscription_count: guild.premiumSubscriptionCount,
823
+ preferred_locale: guild.preferredLocale,
824
+ public_updates_channel_id: guild.publicUpdatesChannelId,
825
+ max_video_channel_users: guild.maxVideoChannelUsers,
826
+ max_stage_video_channel_users: guild.maxStageVideoChannelUsers,
827
+ approximate_member_count: guild.approximateMemberCount,
828
+ approximate_presence_count: guild.approximatePresenceCount,
829
+ welcome_screen: guild.welcomeScreen !== undefined
830
+ ? {
831
+ description: guild.welcomeScreen.description,
832
+ welcome_channels: guild.welcomeScreen.welcomeChannels.map((welcomeScreenChannel) => ({
833
+ channel_id: welcomeScreenChannel.channelId,
834
+ description: welcomeScreenChannel.description,
835
+ emoji_id: welcomeScreenChannel.emojiId,
836
+ emoji_name: welcomeScreenChannel.emojiName,
837
+ })),
838
+ }
839
+ : undefined,
840
+ nsfw_level: guild.nsfwLevel,
841
+ stickers: guild.stickers?.map((sticker) => this.stickerToRaw(sticker)),
842
+ premium_progress_bar_enabled: guild.premiumProgressBarEnabled,
843
+ safety_alerts_channel_id: guild.safetyAlertsChannelId,
844
+ };
845
+ }
846
+ guildMemberFromRaw(guildMember) {
847
+ return {
848
+ user: guildMember.user !== undefined
849
+ ? this.userFromRaw(guildMember.user)
850
+ : undefined,
851
+ nick: guildMember.nick,
852
+ avatar: guildMember.avatar,
853
+ roles: guildMember.roles,
854
+ joinedAt: guildMember.joined_at,
855
+ premiumSince: guildMember.premium_since,
856
+ deaf: guildMember.deaf,
857
+ mute: guildMember.mute,
858
+ flags: guildMember.flags,
859
+ pending: guildMember.pending,
860
+ permissions: guildMember.permissions,
861
+ communicationDisabledUntil: guildMember.communication_disabled_until,
862
+ };
863
+ }
864
+ guildMemberToRaw(guildMember) {
865
+ return {
866
+ user: guildMember.user !== undefined
867
+ ? this.userToRaw(guildMember.user)
868
+ : undefined,
869
+ nick: guildMember.nick,
870
+ avatar: guildMember.avatar,
871
+ roles: guildMember.roles,
872
+ joined_at: guildMember.joinedAt,
873
+ premium_since: guildMember.premiumSince,
874
+ deaf: guildMember.deaf,
875
+ mute: guildMember.mute,
876
+ flags: guildMember.flags,
877
+ pending: guildMember.pending,
878
+ permissions: guildMember.permissions,
879
+ communication_disabled_until: guildMember.communicationDisabledUntil,
880
+ };
881
+ }
882
+ guildScheduledEventFromRaw(guildScheduledEvent) {
883
+ return {
884
+ id: guildScheduledEvent.id,
885
+ guildId: guildScheduledEvent.guild_id,
886
+ channelId: guildScheduledEvent.channel_id,
887
+ creatorId: guildScheduledEvent.creator_id,
888
+ name: guildScheduledEvent.name,
889
+ description: guildScheduledEvent.description,
890
+ scheduledStartTime: guildScheduledEvent.scheduled_start_time,
891
+ scheduledEndTime: guildScheduledEvent.scheduled_end_time,
892
+ privacyLevel: guildScheduledEvent.privacy_level,
893
+ status: guildScheduledEvent.status,
894
+ entityType: guildScheduledEvent.entity_type,
895
+ entityId: guildScheduledEvent.entity_id,
896
+ entityMetadata: guildScheduledEvent.entity_metadata,
897
+ creator: guildScheduledEvent.creator !== undefined
898
+ ? this.userFromRaw(guildScheduledEvent.creator)
899
+ : undefined,
900
+ userCount: guildScheduledEvent.user_count,
901
+ image: guildScheduledEvent.image,
902
+ };
903
+ }
904
+ guildScheduledEventToRaw(guildScheduledEvent) {
905
+ return {
906
+ id: guildScheduledEvent.id,
907
+ guild_id: guildScheduledEvent.guildId,
908
+ channel_id: guildScheduledEvent.channelId,
909
+ creator_id: guildScheduledEvent.creatorId,
910
+ name: guildScheduledEvent.name,
911
+ description: guildScheduledEvent.description,
912
+ scheduled_start_time: guildScheduledEvent.scheduledStartTime,
913
+ scheduled_end_time: guildScheduledEvent.scheduledEndTime,
914
+ privacy_level: guildScheduledEvent.privacyLevel,
915
+ status: guildScheduledEvent.status,
916
+ entity_type: guildScheduledEvent.entityType,
917
+ entity_id: guildScheduledEvent.entityId,
918
+ entity_metadata: guildScheduledEvent.entityMetadata,
919
+ creator: guildScheduledEvent.creator !== undefined
920
+ ? this.userToRaw(guildScheduledEvent.creator)
921
+ : undefined,
922
+ user_count: guildScheduledEvent.userCount,
923
+ image: guildScheduledEvent.image,
924
+ };
925
+ }
926
+ guildTemplateFromRaw(guildTemplate) {
927
+ return {
928
+ code: guildTemplate.code,
929
+ name: guildTemplate.name,
930
+ description: guildTemplate.description,
931
+ usageCount: guildTemplate.usage_count,
932
+ creatorId: guildTemplate.creator_id,
933
+ creator: this.userFromRaw(guildTemplate.creator),
934
+ createdAt: guildTemplate.created_at,
935
+ updatedAt: guildTemplate.updated_at,
936
+ sourceGuildId: guildTemplate.source_guild_id,
937
+ serializedSourceGuild: this.guildFromRaw(guildTemplate.serialized_source_guild),
938
+ isDirty: guildTemplate.is_dirty,
939
+ };
940
+ }
941
+ guildTemplateToRaw(guildTemplate) {
942
+ return {
943
+ code: guildTemplate.code,
944
+ name: guildTemplate.name,
945
+ description: guildTemplate.description,
946
+ usage_count: guildTemplate.usageCount,
947
+ creator_id: guildTemplate.creatorId,
948
+ creator: this.userToRaw(guildTemplate.creator),
949
+ created_at: guildTemplate.createdAt,
950
+ updated_at: guildTemplate.updatedAt,
951
+ source_guild_id: guildTemplate.sourceGuildId,
952
+ serialized_source_guild: this.guildToRaw(guildTemplate.serializedSourceGuild),
953
+ is_dirty: guildTemplate.isDirty,
954
+ };
955
+ }
956
+ integrationFromRaw(integration) {
957
+ return {
958
+ id: integration.id,
959
+ name: integration.name,
960
+ type: integration.type,
961
+ enabled: integration.enabled,
962
+ syncing: integration.syncing,
963
+ roleId: integration.role_id,
964
+ enableEmoticons: integration.enable_emoticons,
965
+ expireBehavior: integration.expire_behavior,
966
+ expireGracePeriod: integration.expire_grace_period,
967
+ user: integration.user !== undefined
968
+ ? this.userFromRaw(integration.user)
969
+ : undefined,
970
+ account: integration.account,
971
+ syncedAt: integration.synced_at,
972
+ subscriberCount: integration.subscriber_count,
973
+ revoked: integration.revoked,
974
+ application: integration.application !== undefined
975
+ ? {
976
+ id: integration.application.id,
977
+ name: integration.application.name,
978
+ icon: integration.application.icon,
979
+ description: integration.application.description,
980
+ bot: integration.application.bot !== undefined
981
+ ? this.userFromRaw(integration.application.bot)
982
+ : undefined,
983
+ }
984
+ : undefined,
985
+ scopes: integration.scopes,
986
+ };
987
+ }
988
+ integrationToRaw(integration) {
989
+ return {
990
+ id: integration.id,
991
+ name: integration.name,
992
+ type: integration.type,
993
+ enabled: integration.enabled,
994
+ syncing: integration.syncing,
995
+ role_id: integration.roleId,
996
+ enable_emoticons: integration.enableEmoticons,
997
+ expire_behavior: integration.expireBehavior,
998
+ expire_grace_period: integration.expireGracePeriod,
999
+ user: integration.user !== undefined
1000
+ ? this.userToRaw(integration.user)
1001
+ : undefined,
1002
+ account: integration.account,
1003
+ synced_at: integration.syncedAt,
1004
+ subscriber_count: integration.subscriberCount,
1005
+ revoked: integration.revoked,
1006
+ application: integration.application !== undefined
1007
+ ? {
1008
+ id: integration.application.id,
1009
+ name: integration.application.name,
1010
+ icon: integration.application.icon,
1011
+ description: integration.application.description,
1012
+ bot: integration.application.bot !== undefined
1013
+ ? this.userToRaw(integration.application.bot)
1014
+ : undefined,
1015
+ }
1016
+ : undefined,
1017
+ scopes: integration.scopes,
1018
+ };
1019
+ }
1020
+ interactionFromRaw(interaction) {
1021
+ return {
1022
+ id: interaction.id,
1023
+ applicationId: interaction.application_id,
1024
+ type: interaction.type,
1025
+ data: interaction.data !== undefined
1026
+ ? {
1027
+ id: interaction.data.id,
1028
+ name: interaction.data.name,
1029
+ type: interaction.data.type,
1030
+ resolved: interaction.data.resolved !== undefined
1031
+ ? this.resolvedDataFromRaw(interaction.data.resolved)
1032
+ : undefined,
1033
+ options: interaction.data.options,
1034
+ guildId: interaction.data.guild_id,
1035
+ targetId: interaction.data.target_id,
1036
+ customId: interaction.data.custom_id,
1037
+ componentType: interaction.data.component_type,
1038
+ values: interaction.data.values,
1039
+ components: interaction.data.components?.map((component) => ({
1040
+ type: component.type,
1041
+ components: component.components?.map((c) => ({
1042
+ type: c.type,
1043
+ customId: c.custom_id,
1044
+ style: c.style,
1045
+ label: c.label,
1046
+ minLength: c.min_length,
1047
+ maxLength: c.max_length,
1048
+ required: c.required,
1049
+ value: c.value,
1050
+ placeholder: c.placeholder,
1051
+ })),
1052
+ })),
1053
+ }
1054
+ : undefined,
1055
+ guildId: interaction.guild_id,
1056
+ channel: interaction.channel !== undefined
1057
+ ? this.channelFromRaw(interaction.channel)
1058
+ : undefined,
1059
+ channelId: interaction.channel_id,
1060
+ member: interaction.member !== undefined
1061
+ ? this.guildMemberFromRaw(interaction.member)
1062
+ : undefined,
1063
+ user: interaction.user !== undefined
1064
+ ? this.userFromRaw(interaction.user)
1065
+ : undefined,
1066
+ token: interaction.token,
1067
+ version: interaction.version,
1068
+ message: interaction.message !== undefined
1069
+ ? this.messageFromRaw(interaction.message)
1070
+ : undefined,
1071
+ appPermissions: interaction.app_permissions,
1072
+ locale: interaction.locale,
1073
+ guildLocale: interaction.guild_locale,
1074
+ entitlements: interaction.entitlements.map((entitlement) => this.entitlementFromRaw(entitlement)),
1075
+ };
1076
+ }
1077
+ interactionToRaw(interaction) {
1078
+ return {
1079
+ id: interaction.id,
1080
+ application_id: interaction.applicationId,
1081
+ type: interaction.type,
1082
+ data: interaction.data !== undefined
1083
+ ? {
1084
+ id: interaction.data.id,
1085
+ name: interaction.data.name,
1086
+ type: interaction.data.type,
1087
+ resolved: interaction.data.resolved !== undefined
1088
+ ? this.resolvedDataToRaw(interaction.data.resolved)
1089
+ : undefined,
1090
+ options: interaction.data.options,
1091
+ guild_id: interaction.data.guildId,
1092
+ target_id: interaction.data.targetId,
1093
+ custom_id: interaction.data.customId,
1094
+ component_type: interaction.data.componentType,
1095
+ values: interaction.data.values,
1096
+ components: interaction.data.components?.map((component) => ({
1097
+ type: component.type,
1098
+ components: component.components?.map((c) => ({
1099
+ type: c.type,
1100
+ custom_id: c.customId,
1101
+ style: c.style,
1102
+ label: c.label,
1103
+ min_length: c.minLength,
1104
+ max_length: c.maxLength,
1105
+ required: c.required,
1106
+ value: c.value,
1107
+ placeholder: c.placeholder,
1108
+ })),
1109
+ })),
1110
+ }
1111
+ : undefined,
1112
+ guild_id: interaction.guildId,
1113
+ channel: interaction.channel !== undefined
1114
+ ? this.channelToRaw(interaction.channel)
1115
+ : undefined,
1116
+ channel_id: interaction.channelId,
1117
+ member: interaction.member !== undefined
1118
+ ? this.guildMemberToRaw(interaction.member)
1119
+ : undefined,
1120
+ user: interaction.user !== undefined
1121
+ ? this.userToRaw(interaction.user)
1122
+ : undefined,
1123
+ token: interaction.token,
1124
+ version: interaction.version,
1125
+ message: interaction.message !== undefined
1126
+ ? this.messageToRaw(interaction.message)
1127
+ : undefined,
1128
+ app_permissions: interaction.appPermissions,
1129
+ locale: interaction.locale,
1130
+ guild_locale: interaction.guildLocale,
1131
+ entitlements: interaction.entitlements.map((entitlement) => this.entitlementToRaw(entitlement)),
1132
+ };
1133
+ }
1134
+ interactionMetadataFromRaw(interactionMetadata) {
1135
+ return {
1136
+ id: interactionMetadata.id,
1137
+ type: interactionMetadata.type,
1138
+ user: this.userFromRaw(interactionMetadata.user),
1139
+ authorizingIntegrationOwners: {
1140
+ "0": interactionMetadata.authorizing_integration_owners[0],
1141
+ "1": interactionMetadata.authorizing_integration_owners[1],
1142
+ },
1143
+ originalResponseMessageId: interactionMetadata.original_response_message_id,
1144
+ interactedMessageId: interactionMetadata.interacted_message_id,
1145
+ triggeringInteractionMetadata: interactionMetadata.triggering_interaction_metadata !== undefined
1146
+ ? this.interactionMetadataFromRaw(interactionMetadata.triggering_interaction_metadata)
1147
+ : undefined,
1148
+ };
1149
+ }
1150
+ interactionMetadataToRaw(interactionMetadata) {
1151
+ return {
1152
+ id: interactionMetadata.id,
1153
+ type: interactionMetadata.type,
1154
+ user: this.userToRaw(interactionMetadata.user),
1155
+ authorizing_integration_owners: {
1156
+ "0": interactionMetadata.authorizingIntegrationOwners[0],
1157
+ "1": interactionMetadata.authorizingIntegrationOwners[1],
1158
+ },
1159
+ original_response_message_id: interactionMetadata.originalResponseMessageId,
1160
+ interacted_message_id: interactionMetadata.interactedMessageId,
1161
+ triggering_interaction_metadata: interactionMetadata.triggeringInteractionMetadata !== undefined
1162
+ ? this.interactionMetadataToRaw(interactionMetadata.triggeringInteractionMetadata)
1163
+ : undefined,
1164
+ };
1165
+ }
1166
+ inviteFromRaw(invite) {
1167
+ return {
1168
+ type: invite.type,
1169
+ code: invite.code,
1170
+ guild: invite.guild !== undefined
1171
+ ? this.guildFromRaw(invite.guild)
1172
+ : undefined,
1173
+ channel: this.channelFromRaw(invite.channel),
1174
+ inviter: invite.inviter !== undefined
1175
+ ? this.userFromRaw(invite.inviter)
1176
+ : undefined,
1177
+ targetType: invite.target_type,
1178
+ targetUser: invite.target_user !== undefined
1179
+ ? this.userFromRaw(invite.target_user)
1180
+ : undefined,
1181
+ targetApplication: invite.target_application !== undefined
1182
+ ? this.applicationFromRaw(invite.target_application)
1183
+ : undefined,
1184
+ approximatePresenceCount: invite.approximate_presence_count,
1185
+ approximateMemberCount: invite.approximate_member_count,
1186
+ expiresAt: invite.expires_at,
1187
+ stageInstance: invite.stage_instance !== undefined
1188
+ ? {
1189
+ members: invite.stage_instance.members.map((guildMember) => this.guildMemberFromRaw(guildMember)),
1190
+ participantCount: invite.stage_instance.participant_count,
1191
+ speakerCount: invite.stage_instance.speaker_count,
1192
+ topic: invite.stage_instance.topic,
1193
+ }
1194
+ : undefined,
1195
+ guildScheduledEvent: invite.guild_scheduled_event !== undefined
1196
+ ? this.guildScheduledEventFromRaw(invite.guild_scheduled_event)
1197
+ : undefined,
1198
+ };
1199
+ }
1200
+ inviteToRaw(invite) {
1201
+ return {
1202
+ type: invite.type,
1203
+ code: invite.code,
1204
+ guild: invite.guild !== undefined ? this.guildToRaw(invite.guild) : undefined,
1205
+ channel: this.channelToRaw(invite.channel),
1206
+ inviter: invite.inviter !== undefined
1207
+ ? this.userToRaw(invite.inviter)
1208
+ : undefined,
1209
+ target_type: invite.targetType,
1210
+ target_user: invite.targetUser !== undefined
1211
+ ? this.userToRaw(invite.targetUser)
1212
+ : undefined,
1213
+ target_application: invite.targetApplication !== undefined
1214
+ ? this.applicationToRaw(invite.targetApplication)
1215
+ : undefined,
1216
+ approximate_presence_count: invite.approximatePresenceCount,
1217
+ approximate_member_count: invite.approximateMemberCount,
1218
+ expires_at: invite.expiresAt,
1219
+ stage_instance: invite.stageInstance !== undefined
1220
+ ? {
1221
+ members: invite.stageInstance.members.map((guildMember) => this.guildMemberToRaw(guildMember)),
1222
+ participant_count: invite.stageInstance.participantCount,
1223
+ speaker_count: invite.stageInstance.speakerCount,
1224
+ topic: invite.stageInstance.topic,
1225
+ }
1226
+ : undefined,
1227
+ guild_scheduled_event: invite.guildScheduledEvent !== undefined
1228
+ ? this.guildScheduledEventToRaw(invite.guildScheduledEvent)
1229
+ : undefined,
1230
+ };
1231
+ }
1232
+ messageComponentsFromRaw(components) {
1233
+ return components.map((component) => ({
1234
+ type: component.type,
1235
+ components: component.components.map((c) => {
1236
+ switch (c.type) {
1237
+ case constants_1.ComponentTypes.Button: {
1238
+ return {
1239
+ type: c.type,
1240
+ style: c.style,
1241
+ label: c.label,
1242
+ emoji: c.emoji !== undefined
1243
+ ? {
1244
+ name: c.emoji.name,
1245
+ id: c.emoji.id,
1246
+ animated: c.emoji.animated,
1247
+ }
1248
+ : undefined,
1249
+ customId: c.custom_id,
1250
+ url: c.url,
1251
+ disabled: c.disabled,
1252
+ };
1253
+ }
1254
+ case constants_1.ComponentTypes.TextInput: {
1255
+ return {
1256
+ type: c.type,
1257
+ customId: c.custom_id,
1258
+ style: c.style,
1259
+ label: c.label,
1260
+ minLength: c.min_length,
1261
+ maxLength: c.max_length,
1262
+ required: c.required,
1263
+ value: c.value,
1264
+ placeholder: c.placeholder,
1265
+ };
1266
+ }
1267
+ case constants_1.ComponentTypes.ChannelSelect: {
1268
+ return {
1269
+ type: c.type,
1270
+ customId: c.custom_id,
1271
+ channelTypes: c.channel_types,
1272
+ placeholder: c.placeholder,
1273
+ defaultValues: c.default_values,
1274
+ minValues: c.min_values,
1275
+ maxValues: c.max_values,
1276
+ disabled: c.disabled,
1277
+ };
1278
+ }
1279
+ case constants_1.ComponentTypes.StringSelect: {
1280
+ return {
1281
+ type: c.type,
1282
+ customId: c.custom_id,
1283
+ placeholder: c.placeholder,
1284
+ options: c.options?.map((option) => ({
1285
+ label: option.label,
1286
+ value: option.value,
1287
+ description: option.description,
1288
+ emoji: option.emoji !== undefined
1289
+ ? {
1290
+ name: option.emoji.name,
1291
+ id: option.emoji.id,
1292
+ animated: option.emoji.animated,
1293
+ }
1294
+ : undefined,
1295
+ default: option.default,
1296
+ })),
1297
+ minValues: c.min_values,
1298
+ maxValues: c.max_values,
1299
+ disabled: c.disabled,
1300
+ };
1301
+ }
1302
+ case constants_1.ComponentTypes.MentionableSelect:
1303
+ case constants_1.ComponentTypes.RoleSelect:
1304
+ case constants_1.ComponentTypes.UserSelect: {
1305
+ return {
1306
+ type: c.type,
1307
+ customId: c.custom_id,
1308
+ placeholder: c.placeholder,
1309
+ defaultValues: c.default_values,
1310
+ minValues: c.min_values,
1311
+ maxValues: c.max_values,
1312
+ disabled: c.disabled,
1313
+ };
1314
+ }
1315
+ }
1316
+ }),
1317
+ }));
1318
+ }
1319
+ messageComponentsToRaw(components) {
1320
+ return components.map((component) => ({
1321
+ type: component.type,
1322
+ components: component.components.map((c) => {
1323
+ switch (c.type) {
1324
+ case constants_1.ComponentTypes.Button: {
1325
+ return {
1326
+ type: c.type,
1327
+ style: c.style,
1328
+ label: c.label,
1329
+ emoji: c.emoji !== undefined
1330
+ ? {
1331
+ name: c.emoji.name,
1332
+ id: c.emoji.id,
1333
+ animated: c.emoji.animated,
1334
+ }
1335
+ : undefined,
1336
+ custom_id: c.customId,
1337
+ url: c.url,
1338
+ disabled: c.disabled,
1339
+ };
1340
+ }
1341
+ case constants_1.ComponentTypes.TextInput: {
1342
+ return {
1343
+ type: c.type,
1344
+ custom_id: c.customId,
1345
+ style: c.style,
1346
+ label: c.label,
1347
+ min_length: c.minLength,
1348
+ max_length: c.maxLength,
1349
+ required: c.required,
1350
+ value: c.value,
1351
+ placeholder: c.placeholder,
1352
+ };
1353
+ }
1354
+ case constants_1.ComponentTypes.ChannelSelect: {
1355
+ return {
1356
+ type: c.type,
1357
+ custom_id: c.customId,
1358
+ channel_types: c.channelTypes,
1359
+ placeholder: c.placeholder,
1360
+ default_values: c.defaultValues,
1361
+ min_values: c.minValues,
1362
+ max_values: c.maxValues,
1363
+ disabled: c.disabled,
1364
+ };
1365
+ }
1366
+ case constants_1.ComponentTypes.StringSelect: {
1367
+ return {
1368
+ type: c.type,
1369
+ custom_id: c.customId,
1370
+ placeholder: c.placeholder,
1371
+ options: c.options?.map((option) => ({
1372
+ label: option.label,
1373
+ value: option.value,
1374
+ description: option.description,
1375
+ emoji: option.emoji !== undefined
1376
+ ? {
1377
+ name: option.emoji.name,
1378
+ id: option.emoji.id,
1379
+ animated: option.emoji.animated,
1380
+ }
1381
+ : undefined,
1382
+ default: option.default,
1383
+ })),
1384
+ min_values: c.minValues,
1385
+ max_values: c.maxValues,
1386
+ disabled: c.disabled,
1387
+ };
1388
+ }
1389
+ case constants_1.ComponentTypes.MentionableSelect:
1390
+ case constants_1.ComponentTypes.RoleSelect:
1391
+ case constants_1.ComponentTypes.UserSelect: {
1392
+ return {
1393
+ type: c.type,
1394
+ custom_id: c.customId,
1395
+ placeholder: c.placeholder,
1396
+ default_values: c.defaultValues,
1397
+ min_values: c.minValues,
1398
+ max_values: c.maxValues,
1399
+ disabled: c.disabled,
1400
+ };
1401
+ }
1402
+ }
1403
+ }),
1404
+ }));
1405
+ }
1406
+ messageFromRaw(message) {
1407
+ return {
1408
+ id: message.id,
1409
+ channelId: message.channel_id,
1410
+ author: this.userFromRaw(message.author),
1411
+ content: message.content,
1412
+ timestamp: message.timestamp,
1413
+ editedTimestamp: message.edited_timestamp,
1414
+ tts: message.tts,
1415
+ mentionEveryone: message.mention_everyone,
1416
+ mentions: message.mentions.map((user) => this.userFromRaw(user)),
1417
+ mentionRoles: message.mention_roles,
1418
+ mentionChannels: message.mention_channels?.map((channelMention) => ({
1419
+ id: channelMention.id,
1420
+ guildId: channelMention.guild_id,
1421
+ type: channelMention.type,
1422
+ name: channelMention.name,
1423
+ })),
1424
+ attachments: message.attachments.map((attachment) => this.attachmentFromRaw(attachment)),
1425
+ embeds: message.embeds,
1426
+ reactions: message.reactions?.map((reaction) => ({
1427
+ count: reaction.count,
1428
+ countDetails: reaction.count_details,
1429
+ me: reaction.me,
1430
+ meBurst: reaction.me_burst,
1431
+ emoji: this.emojiFromRaw(reaction.emoji),
1432
+ burstColors: reaction.burst_colors,
1433
+ })),
1434
+ nonce: message.nonce,
1435
+ pinned: message.pinned,
1436
+ webhookId: message.webhook_id,
1437
+ type: message.type,
1438
+ activity: message.activity,
1439
+ application: message.application !== undefined
1440
+ ? this.applicationFromRaw(message.application)
1441
+ : undefined,
1442
+ applicationId: message.application_id,
1443
+ messageReference: message.message_reference !== undefined
1444
+ ? {
1445
+ messageId: message.message_reference.message_id,
1446
+ channelId: message.message_reference.channel_id,
1447
+ guildId: message.message_reference.guild_id,
1448
+ failIfNotExists: message.message_reference.fail_if_not_exists,
1449
+ }
1450
+ : undefined,
1451
+ flags: message.flags,
1452
+ referencedMessage: message.referenced_message !== undefined
1453
+ ? message.referenced_message !== null
1454
+ ? this.messageFromRaw(message.referenced_message)
1455
+ : null
1456
+ : undefined,
1457
+ interactionMetadata: message.interaction_metadata !== undefined
1458
+ ? this.interactionMetadataFromRaw(message.interaction_metadata)
1459
+ : undefined,
1460
+ interaction: message.interaction !== undefined
1461
+ ? {
1462
+ id: message.interaction.id,
1463
+ type: message.interaction.type,
1464
+ name: message.interaction.name,
1465
+ user: this.userFromRaw(message.interaction.user),
1466
+ member: message.interaction.member !== undefined
1467
+ ? this.guildMemberFromRaw(message.interaction.member)
1468
+ : undefined,
1469
+ }
1470
+ : undefined,
1471
+ thread: message.thread !== undefined
1472
+ ? this.channelFromRaw(message.thread)
1473
+ : undefined,
1474
+ components: message.components !== undefined
1475
+ ? this.messageComponentsFromRaw(message.components)
1476
+ : undefined,
1477
+ stickerItems: message.sticker_items?.map((stickerItem) => ({
1478
+ id: stickerItem.id,
1479
+ name: stickerItem.name,
1480
+ formatType: stickerItem.format_type,
1481
+ })),
1482
+ stickers: message.stickers?.map((sticker) => this.stickerFromRaw(sticker)),
1483
+ position: message.position,
1484
+ roleSubscriptionData: message.role_subscription_data !== undefined
1485
+ ? {
1486
+ roleSubscriptionListingId: message.role_subscription_data.role_subscription_listing_id,
1487
+ tierName: message.role_subscription_data.tier_name,
1488
+ totalMonthsSubscribed: message.role_subscription_data.total_months_subscribed,
1489
+ isRenewal: message.role_subscription_data.is_renewal,
1490
+ }
1491
+ : undefined,
1492
+ resolved: message.resolved !== undefined
1493
+ ? this.resolvedDataFromRaw(message.resolved)
1494
+ : undefined,
1495
+ poll: message.poll !== undefined ? this.pollFromRaw(message.poll) : undefined,
1496
+ call: message.call,
1497
+ };
1498
+ }
1499
+ messageToRaw(message) {
1500
+ return {
1501
+ id: message.id,
1502
+ channel_id: message.channelId,
1503
+ author: this.userToRaw(message.author),
1504
+ content: message.content,
1505
+ timestamp: message.timestamp,
1506
+ edited_timestamp: message.editedTimestamp,
1507
+ tts: message.tts,
1508
+ mention_everyone: message.mentionEveryone,
1509
+ mentions: message.mentions.map((user) => this.userToRaw(user)),
1510
+ mention_roles: message.mentionRoles,
1511
+ mention_channels: message.mentionChannels?.map((channelMention) => ({
1512
+ id: channelMention.id,
1513
+ guild_id: channelMention.guildId,
1514
+ type: channelMention.type,
1515
+ name: channelMention.name,
1516
+ })),
1517
+ attachments: message.attachments.map((attachment) => this.attachmentToRaw(attachment)),
1518
+ embeds: message.embeds,
1519
+ reactions: message.reactions?.map((reaction) => ({
1520
+ count: reaction.count,
1521
+ count_details: reaction.countDetails,
1522
+ me: reaction.me,
1523
+ me_burst: reaction.meBurst,
1524
+ emoji: this.emojiToRaw(reaction.emoji),
1525
+ burst_colors: reaction.burstColors,
1526
+ })),
1527
+ nonce: message.nonce,
1528
+ pinned: message.pinned,
1529
+ webhook_id: message.webhookId,
1530
+ type: message.type,
1531
+ activity: message.activity,
1532
+ application: message.application !== undefined
1533
+ ? this.applicationToRaw(message.application)
1534
+ : undefined,
1535
+ application_id: message.applicationId,
1536
+ message_reference: message.messageReference !== undefined
1537
+ ? {
1538
+ message_id: message.messageReference.messageId,
1539
+ channel_id: message.messageReference.channelId,
1540
+ guild_id: message.messageReference.guildId,
1541
+ fail_if_not_exists: message.messageReference.failIfNotExists,
1542
+ }
1543
+ : undefined,
1544
+ flags: message.flags,
1545
+ referenced_message: message.referencedMessage !== undefined
1546
+ ? message.referencedMessage !== null
1547
+ ? this.messageToRaw(message.referencedMessage)
1548
+ : null
1549
+ : undefined,
1550
+ interaction_metadata: message.interactionMetadata !== undefined
1551
+ ? this.interactionMetadataToRaw(message.interactionMetadata)
1552
+ : undefined,
1553
+ interaction: message.interaction !== undefined
1554
+ ? {
1555
+ id: message.interaction.id,
1556
+ type: message.interaction.type,
1557
+ name: message.interaction.name,
1558
+ user: this.userToRaw(message.interaction.user),
1559
+ member: message.interaction.member !== undefined
1560
+ ? this.guildMemberToRaw(message.interaction.member)
1561
+ : undefined,
1562
+ }
1563
+ : undefined,
1564
+ thread: message.thread !== undefined
1565
+ ? this.channelToRaw(message.thread)
1566
+ : undefined,
1567
+ components: message.components !== undefined
1568
+ ? this.messageComponentsToRaw(message.components)
1569
+ : undefined,
1570
+ sticker_items: message.stickerItems?.map((stickerItem) => ({
1571
+ id: stickerItem.id,
1572
+ name: stickerItem.name,
1573
+ format_type: stickerItem.formatType,
1574
+ })),
1575
+ stickers: message.stickers?.map((sticker) => this.stickerToRaw(sticker)),
1576
+ position: message.position,
1577
+ role_subscription_data: message.roleSubscriptionData !== undefined
1578
+ ? {
1579
+ role_subscription_listing_id: message.roleSubscriptionData.roleSubscriptionListingId,
1580
+ tier_name: message.roleSubscriptionData.tierName,
1581
+ total_months_subscribed: message.roleSubscriptionData.totalMonthsSubscribed,
1582
+ is_renewal: message.roleSubscriptionData.isRenewal,
1583
+ }
1584
+ : undefined,
1585
+ resolved: message.resolved !== undefined
1586
+ ? this.resolvedDataToRaw(message.resolved)
1587
+ : undefined,
1588
+ poll: message.poll !== undefined ? this.pollToRaw(message.poll) : undefined,
1589
+ call: message.call,
1590
+ };
1591
+ }
1592
+ partialApplicationCommandToRaw(applicationCommand) {
1593
+ return {
1594
+ id: applicationCommand.id,
1595
+ type: applicationCommand.type,
1596
+ application_id: applicationCommand.applicationId,
1597
+ guild_id: applicationCommand.guildId,
1598
+ name: applicationCommand.name,
1599
+ name_localizations: applicationCommand.nameLocalizations,
1600
+ description: applicationCommand.description,
1601
+ description_localizations: applicationCommand.descriptionLocalizations,
1602
+ options: applicationCommand.options?.map((option) => ({
1603
+ type: option.type,
1604
+ name: option.name,
1605
+ name_localizations: option.nameLocalizations,
1606
+ description: option.description,
1607
+ description_localizations: option.descriptionLocalizations,
1608
+ required: option.required,
1609
+ choices: option.choices?.map((choice) => ({
1610
+ name: choice.name,
1611
+ name_localizations: choice.nameLocalizations,
1612
+ value: choice.value,
1613
+ })),
1614
+ options: option.options?.map((o) => ({
1615
+ type: o.type,
1616
+ name: o.name,
1617
+ name_localizations: o.nameLocalizations,
1618
+ description: o.description,
1619
+ description_localizations: o.descriptionLocalizations,
1620
+ required: o.required,
1621
+ choices: o.choices?.map((choice) => ({
1622
+ name: choice.name,
1623
+ name_localizations: choice.nameLocalizations,
1624
+ value: choice.value,
1625
+ })),
1626
+ channel_types: o.channelTypes,
1627
+ min_value: o.minValue,
1628
+ max_value: o.maxValue,
1629
+ min_length: o.minLength,
1630
+ max_length: o.maxLength,
1631
+ autocomplete: o.autocomplete,
1632
+ })),
1633
+ channel_types: option.channelTypes,
1634
+ min_value: option.minValue,
1635
+ max_value: option.maxValue,
1636
+ min_length: option.minLength,
1637
+ max_length: option.maxLength,
1638
+ autocomplete: option.autocomplete,
1639
+ })),
1640
+ default_member_permissions: applicationCommand.defaultMemberPermissions,
1641
+ dm_permission: applicationCommand.dmPermission,
1642
+ default_permission: applicationCommand.defaultPermission,
1643
+ nsfw: applicationCommand.nsfw,
1644
+ version: applicationCommand.version,
1645
+ };
1646
+ }
1647
+ presenceFromRaw(presence) {
1648
+ return {
1649
+ user: this.userFromRaw(presence.user),
1650
+ guildId: presence.guild_id,
1651
+ status: presence.status,
1652
+ activities: presence.activities.map((activity) => ({
1653
+ name: activity.name,
1654
+ type: activity.type,
1655
+ url: activity.url,
1656
+ createdAt: activity.created_at,
1657
+ timestamps: activity.timestamps,
1658
+ applicationId: activity.application_id,
1659
+ details: activity.details,
1660
+ state: activity.state,
1661
+ party: activity.party,
1662
+ assets: {
1663
+ largeImage: activity.assets?.large_image,
1664
+ largeText: activity.assets?.large_text,
1665
+ smallImage: activity.assets?.small_image,
1666
+ smallText: activity.assets?.small_text,
1667
+ },
1668
+ secrets: activity.secrets,
1669
+ instance: activity.instance,
1670
+ flags: activity.flags,
1671
+ buttons: activity.buttons,
1672
+ })),
1673
+ clientStatus: presence.client_status,
1674
+ };
1675
+ }
1676
+ presenceToRaw(presence) {
1677
+ return {
1678
+ user: this.userToRaw(presence.user),
1679
+ guild_id: presence.guildId,
1680
+ status: presence.status,
1681
+ activities: presence.activities.map((activity) => ({
1682
+ name: activity.name,
1683
+ type: activity.type,
1684
+ url: activity.url,
1685
+ created_at: activity.createdAt,
1686
+ timestamps: activity.timestamps,
1687
+ application_id: activity.applicationId,
1688
+ details: activity.details,
1689
+ state: activity.state,
1690
+ party: activity.party,
1691
+ assets: {
1692
+ large_image: activity.assets?.largeImage,
1693
+ large_text: activity.assets?.largeText,
1694
+ small_image: activity.assets?.smallImage,
1695
+ small_text: activity.assets?.smallText,
1696
+ },
1697
+ secrets: activity.secrets,
1698
+ instance: activity.instance,
1699
+ flags: activity.flags,
1700
+ buttons: activity.buttons,
1701
+ })),
1702
+ client_status: presence.clientStatus,
1703
+ };
1704
+ }
1705
+ resolvedDataFromRaw(resolvedData) {
1706
+ let users = {};
1707
+ let members = {};
1708
+ let roles = {};
1709
+ let channels = {};
1710
+ let messages = {};
1711
+ let attachments = {};
1712
+ if (resolvedData.users !== undefined) {
1713
+ for (const [key, value] of Object.entries(resolvedData.users)) {
1714
+ users[key] = this.userFromRaw(value);
1715
+ }
1716
+ }
1717
+ if (resolvedData.members !== undefined) {
1718
+ for (const [key, value] of Object.entries(resolvedData.members)) {
1719
+ members[key] = this.guildMemberFromRaw(value);
1720
+ }
1721
+ }
1722
+ if (resolvedData.roles !== undefined) {
1723
+ for (const [key, value] of Object.entries(resolvedData.roles)) {
1724
+ roles[key] = this.roleFromRaw(value);
1725
+ }
1726
+ }
1727
+ if (resolvedData.channels !== undefined) {
1728
+ for (const [key, value] of Object.entries(resolvedData.channels)) {
1729
+ channels[key] = this.channelFromRaw(value);
1730
+ }
1731
+ }
1732
+ if (resolvedData.messages !== undefined) {
1733
+ for (const [key, value] of Object.entries(resolvedData.messages)) {
1734
+ messages[key] = this.messageFromRaw(value);
19
1735
  }
20
1736
  }
21
- else {
22
- return obj;
1737
+ if (resolvedData.attachments !== undefined) {
1738
+ for (const [key, value] of Object.entries(resolvedData.attachments)) {
1739
+ attachments[key] = this.attachmentFromRaw(value);
1740
+ }
23
1741
  }
1742
+ return {
1743
+ users,
1744
+ members,
1745
+ roles,
1746
+ channels,
1747
+ messages,
1748
+ attachments,
1749
+ };
24
1750
  }
25
- toSnakeCase(obj) {
26
- if (obj !== null && typeof obj === "object") {
27
- if (Array.isArray(obj)) {
28
- return obj.map((item) => this.toSnakeCase(item));
1751
+ resolvedDataToRaw(resolvedData) {
1752
+ let users = {};
1753
+ let members = {};
1754
+ let roles = {};
1755
+ let channels = {};
1756
+ let messages = {};
1757
+ let attachments = {};
1758
+ if (resolvedData.users !== undefined) {
1759
+ for (const [key, value] of Object.entries(resolvedData.users)) {
1760
+ users[key] = this.userToRaw(value);
29
1761
  }
30
- else {
31
- const newObj = {};
32
- for (const key in obj) {
33
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
34
- const newKey = key.replace(/[A-Z]/g, (match) => `_${match.toLowerCase()}`);
35
- newObj[newKey] = this.toSnakeCase(obj[key]);
36
- }
37
- }
38
- return newObj;
1762
+ }
1763
+ if (resolvedData.members !== undefined) {
1764
+ for (const [key, value] of Object.entries(resolvedData.members)) {
1765
+ members[key] = this.guildMemberToRaw(value);
1766
+ }
1767
+ }
1768
+ if (resolvedData.roles !== undefined) {
1769
+ for (const [key, value] of Object.entries(resolvedData.roles)) {
1770
+ roles[key] = this.roleToRaw(value);
1771
+ }
1772
+ }
1773
+ if (resolvedData.channels !== undefined) {
1774
+ for (const [key, value] of Object.entries(resolvedData.channels)) {
1775
+ channels[key] = this.channelToRaw(value);
1776
+ }
1777
+ }
1778
+ if (resolvedData.messages !== undefined) {
1779
+ for (const [key, value] of Object.entries(resolvedData.messages)) {
1780
+ messages[key] = this.messageToRaw(value);
39
1781
  }
40
1782
  }
41
- else {
42
- return obj;
1783
+ if (resolvedData.attachments !== undefined) {
1784
+ for (const [key, value] of Object.entries(resolvedData.attachments)) {
1785
+ attachments[key] = this.attachmentToRaw(value);
1786
+ }
43
1787
  }
1788
+ return {
1789
+ users,
1790
+ members,
1791
+ roles,
1792
+ channels,
1793
+ messages,
1794
+ attachments,
1795
+ };
1796
+ }
1797
+ pollFromRaw(poll) {
1798
+ return {
1799
+ question: poll.question,
1800
+ answers: poll.answers.map((answer) => ({
1801
+ answerId: answer.answer_id,
1802
+ pollMedia: answer.poll_media,
1803
+ })),
1804
+ expiry: poll.expiry,
1805
+ allowMultiselect: poll.allow_multiselect,
1806
+ layoutType: poll.layout_type,
1807
+ results: poll.results !== undefined
1808
+ ? {
1809
+ isFinalized: poll.results.is_finalized,
1810
+ answerCounts: poll.results.answer_counts.map((answerCount) => ({
1811
+ id: answerCount.id,
1812
+ count: answerCount.count,
1813
+ meVoted: answerCount.me_voted,
1814
+ })),
1815
+ }
1816
+ : undefined,
1817
+ };
1818
+ }
1819
+ pollToRaw(poll) {
1820
+ return {
1821
+ question: poll.question,
1822
+ answers: poll.answers.map((answer) => ({
1823
+ answer_id: answer.answerId,
1824
+ poll_media: answer.pollMedia,
1825
+ })),
1826
+ expiry: poll.expiry,
1827
+ allow_multiselect: poll.allowMultiselect,
1828
+ layout_type: poll.layoutType,
1829
+ results: poll.results !== undefined
1830
+ ? {
1831
+ is_finalized: poll.results.isFinalized,
1832
+ answer_counts: poll.results.answerCounts.map((answerCount) => ({
1833
+ id: answerCount.id,
1834
+ count: answerCount.count,
1835
+ me_voted: answerCount.meVoted,
1836
+ })),
1837
+ }
1838
+ : undefined,
1839
+ };
1840
+ }
1841
+ roleFromRaw(role) {
1842
+ return {
1843
+ id: role.id,
1844
+ name: role.name,
1845
+ color: role.color,
1846
+ hoist: role.hoist,
1847
+ icon: role.icon,
1848
+ unicodeEmoji: role.unicode_emoji,
1849
+ position: role.position,
1850
+ permissions: role.permissions,
1851
+ managed: role.managed,
1852
+ mentionable: role.mentionable,
1853
+ tags: role.tags !== undefined
1854
+ ? {
1855
+ botId: role.tags.bot_id,
1856
+ integrationId: role.tags.integration_id,
1857
+ premiumSubscriber: role.tags.premium_subscriber,
1858
+ subscriptionListingId: role.tags.subscription_listing_id,
1859
+ availableForPurchase: role.tags.available_for_purchase,
1860
+ guildConnections: role.tags.guild_connections,
1861
+ }
1862
+ : undefined,
1863
+ flags: role.flags,
1864
+ };
1865
+ }
1866
+ roleToRaw(role) {
1867
+ return {
1868
+ id: role.id,
1869
+ name: role.name,
1870
+ color: role.color,
1871
+ hoist: role.hoist,
1872
+ icon: role.icon,
1873
+ unicode_emoji: role.unicodeEmoji,
1874
+ position: role.position,
1875
+ permissions: role.permissions,
1876
+ managed: role.managed,
1877
+ mentionable: role.mentionable,
1878
+ tags: role.tags !== undefined
1879
+ ? {
1880
+ bot_id: role.tags.botId,
1881
+ integration_id: role.tags.integrationId,
1882
+ premium_subscriber: role.tags.premiumSubscriber,
1883
+ subscription_listing_id: role.tags.subscriptionListingId,
1884
+ available_for_purchase: role.tags.availableForPurchase,
1885
+ guild_connections: role.tags.guildConnections,
1886
+ }
1887
+ : undefined,
1888
+ flags: role.flags,
1889
+ };
1890
+ }
1891
+ skuFromRaw(sku) {
1892
+ return {
1893
+ id: sku.id,
1894
+ type: sku.type,
1895
+ dependentSkuId: sku.dependent_sku_id,
1896
+ applicationId: sku.application_id,
1897
+ manifestLabels: sku.manifest_labels,
1898
+ accessType: sku.access_type,
1899
+ name: sku.name,
1900
+ features: sku.features,
1901
+ releaseDate: sku.release_date,
1902
+ slug: sku.slug,
1903
+ flags: sku.flags,
1904
+ showAgeGate: sku.show_age_gate,
1905
+ };
1906
+ }
1907
+ skuToRaw(sku) {
1908
+ return {
1909
+ id: sku.id,
1910
+ type: sku.type,
1911
+ dependent_sku_id: sku.dependentSkuId,
1912
+ application_id: sku.applicationId,
1913
+ manifest_labels: sku.manifestLabels,
1914
+ access_type: sku.accessType,
1915
+ name: sku.name,
1916
+ features: sku.features,
1917
+ release_date: sku.releaseDate,
1918
+ slug: sku.slug,
1919
+ flags: sku.flags,
1920
+ show_age_gate: sku.showAgeGate,
1921
+ };
1922
+ }
1923
+ stageInstanceFromRaw(stageInstance) {
1924
+ return {
1925
+ id: stageInstance.id,
1926
+ guildId: stageInstance.guild_id,
1927
+ channelId: stageInstance.channel_id,
1928
+ topic: stageInstance.topic,
1929
+ privacyLevel: stageInstance.privacy_level,
1930
+ discoverableDisabled: stageInstance.discoverable_disabled,
1931
+ guildScheduledEventId: stageInstance.guild_scheduled_event_id,
1932
+ };
1933
+ }
1934
+ stageInstanceToRaw(stageInstance) {
1935
+ return {
1936
+ id: stageInstance.id,
1937
+ guild_id: stageInstance.guildId,
1938
+ channel_id: stageInstance.channelId,
1939
+ topic: stageInstance.topic,
1940
+ privacy_level: stageInstance.privacyLevel,
1941
+ discoverable_disabled: stageInstance.discoverableDisabled,
1942
+ guild_scheduled_event_id: stageInstance.guildScheduledEventId,
1943
+ };
1944
+ }
1945
+ stickerFromRaw(sticker) {
1946
+ return {
1947
+ id: sticker.id,
1948
+ packId: sticker.pack_id,
1949
+ name: sticker.name,
1950
+ description: sticker.description,
1951
+ tags: sticker.tags,
1952
+ asset: sticker.asset,
1953
+ type: sticker.type,
1954
+ formatType: sticker.format_type,
1955
+ available: sticker.available,
1956
+ guildId: sticker.id,
1957
+ user: sticker.user !== undefined ? this.userFromRaw(sticker.user) : undefined,
1958
+ sortValue: sticker.sort_value,
1959
+ };
1960
+ }
1961
+ stickerToRaw(sticker) {
1962
+ return {
1963
+ id: sticker.id,
1964
+ pack_id: sticker.packId,
1965
+ name: sticker.name,
1966
+ description: sticker.description,
1967
+ tags: sticker.tags,
1968
+ asset: sticker.asset,
1969
+ type: sticker.type,
1970
+ format_type: sticker.formatType,
1971
+ available: sticker.available,
1972
+ guild_id: sticker.id,
1973
+ user: sticker.user !== undefined ? this.userToRaw(sticker.user) : undefined,
1974
+ sort_value: sticker.sortValue,
1975
+ };
1976
+ }
1977
+ teamFromRaw(team) {
1978
+ return {
1979
+ icon: team.icon,
1980
+ id: team.id,
1981
+ members: team.members.map((teamMember) => ({
1982
+ membershipState: teamMember.membership_state,
1983
+ teamId: teamMember.team_id,
1984
+ user: this.userFromRaw(teamMember.user),
1985
+ role: teamMember.role,
1986
+ })),
1987
+ name: team.name,
1988
+ ownerUserId: team.owner_user_id,
1989
+ };
1990
+ }
1991
+ teamToRaw(team) {
1992
+ return {
1993
+ icon: team.icon,
1994
+ id: team.id,
1995
+ members: team.members.map((teamMember) => ({
1996
+ membership_state: teamMember.membershipState,
1997
+ team_id: teamMember.teamId,
1998
+ user: this.userToRaw(teamMember.user),
1999
+ role: teamMember.role,
2000
+ })),
2001
+ name: team.name,
2002
+ owner_user_id: team.ownerUserId,
2003
+ };
2004
+ }
2005
+ testEntitlementFromRaw(entitlement) {
2006
+ return {
2007
+ id: entitlement.id,
2008
+ skuId: entitlement.sku_id,
2009
+ applicationId: entitlement.application_id,
2010
+ userId: entitlement.user_id,
2011
+ promotionId: entitlement.promotion_id,
2012
+ type: entitlement.type,
2013
+ deleted: entitlement.deleted,
2014
+ giftCodeFlags: entitlement.gift_code_flags,
2015
+ consumed: entitlement.consumed,
2016
+ guildId: entitlement.guild_id,
2017
+ };
2018
+ }
2019
+ testEntitlementToRaw(entitlement) {
2020
+ return {
2021
+ id: entitlement.id,
2022
+ sku_id: entitlement.skuId,
2023
+ application_id: entitlement.applicationId,
2024
+ user_id: entitlement.userId,
2025
+ promotion_id: entitlement.promotionId,
2026
+ type: entitlement.type,
2027
+ deleted: entitlement.deleted,
2028
+ gift_code_flags: entitlement.giftCodeFlags,
2029
+ consumed: entitlement.consumed,
2030
+ guild_id: entitlement.guildId,
2031
+ };
2032
+ }
2033
+ userFromRaw(user) {
2034
+ return {
2035
+ id: user.id,
2036
+ username: user.username,
2037
+ discriminator: user.discriminator,
2038
+ globalName: user.global_name,
2039
+ avatar: user.avatar,
2040
+ bot: user.bot,
2041
+ system: user.system,
2042
+ mfaEnabled: user.mfa_enabled,
2043
+ banner: user.banner,
2044
+ accentColor: user.accent_color,
2045
+ locale: user.locale,
2046
+ verified: user.verified,
2047
+ email: user.email,
2048
+ flags: user.flags,
2049
+ premiumType: user.premium_type,
2050
+ publicFlags: user.public_flags,
2051
+ avatarDecoration: user.avatar_decoration,
2052
+ };
2053
+ }
2054
+ userToRaw(user) {
2055
+ return {
2056
+ id: user.id,
2057
+ username: user.username,
2058
+ discriminator: user.discriminator,
2059
+ global_name: user.globalName,
2060
+ avatar: user.avatar,
2061
+ bot: user.bot,
2062
+ system: user.system,
2063
+ mfa_enabled: user.mfaEnabled,
2064
+ banner: user.banner,
2065
+ accent_color: user.accentColor,
2066
+ locale: user.locale,
2067
+ verified: user.verified,
2068
+ email: user.email,
2069
+ flags: user.flags,
2070
+ premium_type: user.premiumType,
2071
+ public_flags: user.publicFlags,
2072
+ avatar_decoration: user.avatarDecoration,
2073
+ };
2074
+ }
2075
+ voiceStateFromRaw(voiceState) {
2076
+ return {
2077
+ guildId: voiceState.guild_id,
2078
+ channelId: voiceState.channel_id,
2079
+ userId: voiceState.user_id,
2080
+ member: voiceState.member !== undefined
2081
+ ? this.guildMemberFromRaw(voiceState.member)
2082
+ : undefined,
2083
+ sessionId: voiceState.session_id,
2084
+ deaf: voiceState.deaf,
2085
+ mute: voiceState.mute,
2086
+ selfDeaf: voiceState.self_deaf,
2087
+ selfMute: voiceState.self_mute,
2088
+ selfStream: voiceState.self_stream,
2089
+ selfVideo: voiceState.self_video,
2090
+ suppress: voiceState.suppress,
2091
+ requestToSpeakTimestamp: voiceState.request_to_speak_timestamp,
2092
+ };
2093
+ }
2094
+ voiceStateToRaw(voiceState) {
2095
+ return {
2096
+ guild_id: voiceState.guildId,
2097
+ channel_id: voiceState.channelId,
2098
+ user_id: voiceState.userId,
2099
+ member: voiceState.member !== undefined
2100
+ ? this.guildMemberToRaw(voiceState.member)
2101
+ : undefined,
2102
+ session_id: voiceState.sessionId,
2103
+ deaf: voiceState.deaf,
2104
+ mute: voiceState.mute,
2105
+ self_deaf: voiceState.selfDeaf,
2106
+ self_mute: voiceState.selfMute,
2107
+ self_stream: voiceState.selfStream,
2108
+ self_video: voiceState.selfVideo,
2109
+ suppress: voiceState.suppress,
2110
+ request_to_speak_timestamp: voiceState.requestToSpeakTimestamp,
2111
+ };
2112
+ }
2113
+ webhookFromRaw(webhook) {
2114
+ return {
2115
+ id: webhook.id,
2116
+ type: webhook.type,
2117
+ guildId: webhook.guild_id,
2118
+ channelId: webhook.channel_id,
2119
+ user: webhook.user !== undefined ? this.userFromRaw(webhook.user) : undefined,
2120
+ name: webhook.name,
2121
+ avatar: webhook.avatar,
2122
+ token: webhook.token,
2123
+ applicationId: webhook.application_id,
2124
+ sourceGuild: webhook.source_guild !== undefined
2125
+ ? this.guildFromRaw(webhook.source_guild)
2126
+ : undefined,
2127
+ sourceChannel: webhook.source_channel !== undefined
2128
+ ? this.channelFromRaw(webhook.source_channel)
2129
+ : undefined,
2130
+ url: webhook.url,
2131
+ };
2132
+ }
2133
+ webhookToRaw(webhook) {
2134
+ return {
2135
+ id: webhook.id,
2136
+ type: webhook.type,
2137
+ guild_id: webhook.guildId,
2138
+ channel_id: webhook.channelId,
2139
+ user: webhook.user !== undefined ? this.userToRaw(webhook.user) : undefined,
2140
+ name: webhook.name,
2141
+ avatar: webhook.avatar,
2142
+ token: webhook.token,
2143
+ application_id: webhook.applicationId,
2144
+ source_guild: webhook.sourceGuild !== undefined
2145
+ ? this.guildToRaw(webhook.sourceGuild)
2146
+ : undefined,
2147
+ source_channel: webhook.sourceChannel !== undefined
2148
+ ? this.channelToRaw(webhook.sourceChannel)
2149
+ : undefined,
2150
+ url: webhook.url,
2151
+ };
44
2152
  }
45
2153
  }
46
2154
  exports.Util = Util;