disgroove 2.2.0-dev.15819eb → 2.2.0-dev.4623b99

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,2224 @@
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,
16
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,
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,
583
+ }
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
+ guildApplicationCommandPermissionsFromRaw(guildApplicationCommandPermissions) {
733
+ return {
734
+ id: guildApplicationCommandPermissions.id,
735
+ applicationId: guildApplicationCommandPermissions.application_id,
736
+ guildId: guildApplicationCommandPermissions.guild_id,
737
+ permissions: guildApplicationCommandPermissions.permissions.map((permission) => ({
738
+ id: permission.id,
739
+ type: permission.type,
740
+ permission: permission.permission,
741
+ })),
742
+ };
743
+ }
744
+ guildApplicationCommandPermissionsToRaw(guildApplicationCommandPermissions) {
745
+ return {
746
+ id: guildApplicationCommandPermissions.id,
747
+ application_id: guildApplicationCommandPermissions.applicationId,
748
+ guild_id: guildApplicationCommandPermissions.guildId,
749
+ permissions: guildApplicationCommandPermissions.permissions.map((permission) => ({
750
+ id: permission.id,
751
+ type: permission.type,
752
+ permission: permission.permission,
753
+ })),
754
+ };
755
+ }
756
+ guildFromRaw(guild) {
757
+ return {
758
+ id: guild.id,
759
+ name: guild.name,
760
+ icon: guild.icon,
761
+ iconHash: guild.icon,
762
+ splash: guild.splash,
763
+ discoverySplash: guild.discovery_splash,
764
+ owner: guild.owner,
765
+ ownerId: guild.owner_id,
766
+ permissions: guild.permissions,
767
+ region: guild.region,
768
+ afkChannelId: guild.afk_channel_id,
769
+ afkTimeout: guild.afk_timeout,
770
+ widgetEnabled: guild.widget_enabled,
771
+ widgetChannelId: guild.widget_channel_id,
772
+ verificationLevel: guild.verification_level,
773
+ defaultMessageNotifications: guild.default_message_notifications,
774
+ explicitContentFilter: guild.explicit_content_filter,
775
+ roles: guild.roles.map((role) => this.roleFromRaw(role)),
776
+ emojis: guild.emojis.map((emoji) => this.emojiFromRaw(emoji)),
777
+ features: guild.features,
778
+ mfaLevel: guild.mfa_level,
779
+ applicationId: guild.application_id,
780
+ systemChannelId: guild.system_channel_id,
781
+ systemChannelFlags: guild.system_channel_flags,
782
+ rulesChannelId: guild.rules_channel_id,
783
+ maxPresences: guild.max_presences,
784
+ maxMembers: guild.max_members,
785
+ vanityUrlCode: guild.vanity_url_code,
786
+ description: guild.description,
787
+ banner: guild.banner,
788
+ premiumTier: guild.premium_tier,
789
+ premiumSubscriptionCount: guild.premium_subscription_count,
790
+ preferredLocale: guild.preferred_locale,
791
+ publicUpdatesChannelId: guild.public_updates_channel_id,
792
+ maxVideoChannelUsers: guild.max_video_channel_users,
793
+ maxStageVideoChannelUsers: guild.max_stage_video_channel_users,
794
+ approximateMemberCount: guild.approximate_member_count,
795
+ approximatePresenceCount: guild.approximate_presence_count,
796
+ welcomeScreen: guild.welcome_screen !== undefined
797
+ ? {
798
+ description: guild.welcome_screen.description,
799
+ welcomeChannels: guild.welcome_screen.welcome_channels.map((welcomeScreenChannel) => ({
800
+ channelId: welcomeScreenChannel.channel_id,
801
+ description: welcomeScreenChannel.description,
802
+ emojiId: welcomeScreenChannel.emoji_id,
803
+ emojiName: welcomeScreenChannel.emoji_name,
804
+ })),
805
+ }
806
+ : undefined,
807
+ nsfwLevel: guild.nsfw_level,
808
+ stickers: guild.stickers?.map((sticker) => this.stickerFromRaw(sticker)),
809
+ premiumProgressBarEnabled: guild.premium_progress_bar_enabled,
810
+ safetyAlertsChannelId: guild.safety_alerts_channel_id,
811
+ };
812
+ }
813
+ guildToRaw(guild) {
814
+ return {
815
+ id: guild.id,
816
+ name: guild.name,
817
+ icon: guild.icon,
818
+ icon_hash: guild.icon,
819
+ splash: guild.splash,
820
+ discovery_splash: guild.discoverySplash,
821
+ owner: guild.owner,
822
+ owner_id: guild.ownerId,
823
+ permissions: guild.permissions,
824
+ region: guild.region,
825
+ afk_channel_id: guild.afkChannelId,
826
+ afk_timeout: guild.afkTimeout,
827
+ widget_enabled: guild.widgetEnabled,
828
+ widget_channel_id: guild.widgetChannelId,
829
+ verification_level: guild.verificationLevel,
830
+ default_message_notifications: guild.defaultMessageNotifications,
831
+ explicit_content_filter: guild.explicitContentFilter,
832
+ roles: guild.roles.map((role) => this.roleToRaw(role)),
833
+ emojis: guild.emojis.map((emoji) => this.emojiToRaw(emoji)),
834
+ features: guild.features,
835
+ mfa_level: guild.mfaLevel,
836
+ application_id: guild.applicationId,
837
+ system_channel_id: guild.systemChannelId,
838
+ system_channel_flags: guild.systemChannelFlags,
839
+ rules_channel_id: guild.rulesChannelId,
840
+ max_presences: guild.maxPresences,
841
+ max_members: guild.maxMembers,
842
+ vanity_url_code: guild.vanityUrlCode,
843
+ description: guild.description,
844
+ banner: guild.banner,
845
+ premium_tier: guild.premiumTier,
846
+ premium_subscription_count: guild.premiumSubscriptionCount,
847
+ preferred_locale: guild.preferredLocale,
848
+ public_updates_channel_id: guild.publicUpdatesChannelId,
849
+ max_video_channel_users: guild.maxVideoChannelUsers,
850
+ max_stage_video_channel_users: guild.maxStageVideoChannelUsers,
851
+ approximate_member_count: guild.approximateMemberCount,
852
+ approximate_presence_count: guild.approximatePresenceCount,
853
+ welcome_screen: guild.welcomeScreen !== undefined
854
+ ? {
855
+ description: guild.welcomeScreen.description,
856
+ welcome_channels: guild.welcomeScreen.welcomeChannels.map((welcomeScreenChannel) => ({
857
+ channel_id: welcomeScreenChannel.channelId,
858
+ description: welcomeScreenChannel.description,
859
+ emoji_id: welcomeScreenChannel.emojiId,
860
+ emoji_name: welcomeScreenChannel.emojiName,
861
+ })),
862
+ }
863
+ : undefined,
864
+ nsfw_level: guild.nsfwLevel,
865
+ stickers: guild.stickers?.map((sticker) => this.stickerToRaw(sticker)),
866
+ premium_progress_bar_enabled: guild.premiumProgressBarEnabled,
867
+ safety_alerts_channel_id: guild.safetyAlertsChannelId,
868
+ };
869
+ }
870
+ guildMemberFromRaw(guildMember) {
871
+ return {
872
+ user: guildMember.user !== undefined
873
+ ? this.userFromRaw(guildMember.user)
874
+ : undefined,
875
+ nick: guildMember.nick,
876
+ avatar: guildMember.avatar,
877
+ roles: guildMember.roles,
878
+ joinedAt: guildMember.joined_at,
879
+ premiumSince: guildMember.premium_since,
880
+ deaf: guildMember.deaf,
881
+ mute: guildMember.mute,
882
+ flags: guildMember.flags,
883
+ pending: guildMember.pending,
884
+ permissions: guildMember.permissions,
885
+ communicationDisabledUntil: guildMember.communication_disabled_until,
886
+ };
887
+ }
888
+ guildMemberToRaw(guildMember) {
889
+ return {
890
+ user: guildMember.user !== undefined
891
+ ? this.userToRaw(guildMember.user)
892
+ : undefined,
893
+ nick: guildMember.nick,
894
+ avatar: guildMember.avatar,
895
+ roles: guildMember.roles,
896
+ joined_at: guildMember.joinedAt,
897
+ premium_since: guildMember.premiumSince,
898
+ deaf: guildMember.deaf,
899
+ mute: guildMember.mute,
900
+ flags: guildMember.flags,
901
+ pending: guildMember.pending,
902
+ permissions: guildMember.permissions,
903
+ communication_disabled_until: guildMember.communicationDisabledUntil,
904
+ };
905
+ }
906
+ guildScheduledEventFromRaw(guildScheduledEvent) {
907
+ return {
908
+ id: guildScheduledEvent.id,
909
+ guildId: guildScheduledEvent.guild_id,
910
+ channelId: guildScheduledEvent.channel_id,
911
+ creatorId: guildScheduledEvent.creator_id,
912
+ name: guildScheduledEvent.name,
913
+ description: guildScheduledEvent.description,
914
+ scheduledStartTime: guildScheduledEvent.scheduled_start_time,
915
+ scheduledEndTime: guildScheduledEvent.scheduled_end_time,
916
+ privacyLevel: guildScheduledEvent.privacy_level,
917
+ status: guildScheduledEvent.status,
918
+ entityType: guildScheduledEvent.entity_type,
919
+ entityId: guildScheduledEvent.entity_id,
920
+ entityMetadata: guildScheduledEvent.entity_metadata,
921
+ creator: guildScheduledEvent.creator !== undefined
922
+ ? this.userFromRaw(guildScheduledEvent.creator)
923
+ : undefined,
924
+ userCount: guildScheduledEvent.user_count,
925
+ image: guildScheduledEvent.image,
926
+ };
927
+ }
928
+ guildScheduledEventToRaw(guildScheduledEvent) {
929
+ return {
930
+ id: guildScheduledEvent.id,
931
+ guild_id: guildScheduledEvent.guildId,
932
+ channel_id: guildScheduledEvent.channelId,
933
+ creator_id: guildScheduledEvent.creatorId,
934
+ name: guildScheduledEvent.name,
935
+ description: guildScheduledEvent.description,
936
+ scheduled_start_time: guildScheduledEvent.scheduledStartTime,
937
+ scheduled_end_time: guildScheduledEvent.scheduledEndTime,
938
+ privacy_level: guildScheduledEvent.privacyLevel,
939
+ status: guildScheduledEvent.status,
940
+ entity_type: guildScheduledEvent.entityType,
941
+ entity_id: guildScheduledEvent.entityId,
942
+ entity_metadata: guildScheduledEvent.entityMetadata,
943
+ creator: guildScheduledEvent.creator !== undefined
944
+ ? this.userToRaw(guildScheduledEvent.creator)
945
+ : undefined,
946
+ user_count: guildScheduledEvent.userCount,
947
+ image: guildScheduledEvent.image,
948
+ };
949
+ }
950
+ guildTemplateFromRaw(guildTemplate) {
951
+ return {
952
+ code: guildTemplate.code,
953
+ name: guildTemplate.name,
954
+ description: guildTemplate.description,
955
+ usageCount: guildTemplate.usage_count,
956
+ creatorId: guildTemplate.creator_id,
957
+ creator: this.userFromRaw(guildTemplate.creator),
958
+ createdAt: guildTemplate.created_at,
959
+ updatedAt: guildTemplate.updated_at,
960
+ sourceGuildId: guildTemplate.source_guild_id,
961
+ serializedSourceGuild: this.guildFromRaw(guildTemplate.serialized_source_guild),
962
+ isDirty: guildTemplate.is_dirty,
963
+ };
964
+ }
965
+ guildTemplateToRaw(guildTemplate) {
966
+ return {
967
+ code: guildTemplate.code,
968
+ name: guildTemplate.name,
969
+ description: guildTemplate.description,
970
+ usage_count: guildTemplate.usageCount,
971
+ creator_id: guildTemplate.creatorId,
972
+ creator: this.userToRaw(guildTemplate.creator),
973
+ created_at: guildTemplate.createdAt,
974
+ updated_at: guildTemplate.updatedAt,
975
+ source_guild_id: guildTemplate.sourceGuildId,
976
+ serialized_source_guild: this.guildToRaw(guildTemplate.serializedSourceGuild),
977
+ is_dirty: guildTemplate.isDirty,
978
+ };
979
+ }
980
+ integrationFromRaw(integration) {
981
+ return {
982
+ id: integration.id,
983
+ name: integration.name,
984
+ type: integration.type,
985
+ enabled: integration.enabled,
986
+ syncing: integration.syncing,
987
+ roleId: integration.role_id,
988
+ enableEmoticons: integration.enable_emoticons,
989
+ expireBehavior: integration.expire_behavior,
990
+ expireGracePeriod: integration.expire_grace_period,
991
+ user: integration.user !== undefined
992
+ ? this.userFromRaw(integration.user)
993
+ : undefined,
994
+ account: integration.account,
995
+ syncedAt: integration.synced_at,
996
+ subscriberCount: integration.subscriber_count,
997
+ revoked: integration.revoked,
998
+ application: integration.application !== undefined
999
+ ? {
1000
+ id: integration.application.id,
1001
+ name: integration.application.name,
1002
+ icon: integration.application.icon,
1003
+ description: integration.application.description,
1004
+ bot: integration.application.bot !== undefined
1005
+ ? this.userFromRaw(integration.application.bot)
1006
+ : undefined,
1007
+ }
1008
+ : undefined,
1009
+ scopes: integration.scopes,
1010
+ };
1011
+ }
1012
+ integrationToRaw(integration) {
1013
+ return {
1014
+ id: integration.id,
1015
+ name: integration.name,
1016
+ type: integration.type,
1017
+ enabled: integration.enabled,
1018
+ syncing: integration.syncing,
1019
+ role_id: integration.roleId,
1020
+ enable_emoticons: integration.enableEmoticons,
1021
+ expire_behavior: integration.expireBehavior,
1022
+ expire_grace_period: integration.expireGracePeriod,
1023
+ user: integration.user !== undefined
1024
+ ? this.userToRaw(integration.user)
1025
+ : undefined,
1026
+ account: integration.account,
1027
+ synced_at: integration.syncedAt,
1028
+ subscriber_count: integration.subscriberCount,
1029
+ revoked: integration.revoked,
1030
+ application: integration.application !== undefined
1031
+ ? {
1032
+ id: integration.application.id,
1033
+ name: integration.application.name,
1034
+ icon: integration.application.icon,
1035
+ description: integration.application.description,
1036
+ bot: integration.application.bot !== undefined
1037
+ ? this.userToRaw(integration.application.bot)
1038
+ : undefined,
1039
+ }
1040
+ : undefined,
1041
+ scopes: integration.scopes,
1042
+ };
1043
+ }
1044
+ interactionFromRaw(interaction) {
1045
+ return {
1046
+ id: interaction.id,
1047
+ applicationId: interaction.application_id,
1048
+ type: interaction.type,
1049
+ data: interaction.data !== undefined
1050
+ ? {
1051
+ id: interaction.data.id,
1052
+ name: interaction.data.name,
1053
+ type: interaction.data.type,
1054
+ resolved: interaction.data.resolved !== undefined
1055
+ ? this.resolvedDataFromRaw(interaction.data.resolved)
1056
+ : undefined,
1057
+ options: interaction.data.options,
1058
+ guildId: interaction.data.guild_id,
1059
+ targetId: interaction.data.target_id,
1060
+ customId: interaction.data.custom_id,
1061
+ componentType: interaction.data.component_type,
1062
+ values: interaction.data.values,
1063
+ components: interaction.data.components?.map((component) => ({
1064
+ type: component.type,
1065
+ components: component.components?.map((c) => ({
1066
+ type: c.type,
1067
+ customId: c.custom_id,
1068
+ style: c.style,
1069
+ label: c.label,
1070
+ minLength: c.min_length,
1071
+ maxLength: c.max_length,
1072
+ required: c.required,
1073
+ value: c.value,
1074
+ placeholder: c.placeholder,
1075
+ })),
1076
+ })),
17
1077
  }
18
- return newObj;
1078
+ : undefined,
1079
+ guild: interaction.guild !== undefined
1080
+ ? {
1081
+ locale: interaction.guild.locale,
1082
+ id: interaction.guild.id,
1083
+ features: interaction.guild.features,
1084
+ }
1085
+ : undefined,
1086
+ guildId: interaction.guild_id,
1087
+ channel: interaction.channel !== undefined
1088
+ ? this.channelFromRaw(interaction.channel)
1089
+ : undefined,
1090
+ channelId: interaction.channel_id,
1091
+ member: interaction.member !== undefined
1092
+ ? this.guildMemberFromRaw(interaction.member)
1093
+ : undefined,
1094
+ user: interaction.user !== undefined
1095
+ ? this.userFromRaw(interaction.user)
1096
+ : undefined,
1097
+ token: interaction.token,
1098
+ version: interaction.version,
1099
+ message: interaction.message !== undefined
1100
+ ? this.messageFromRaw(interaction.message)
1101
+ : undefined,
1102
+ appPermissions: interaction.app_permissions,
1103
+ locale: interaction.locale,
1104
+ guildLocale: interaction.guild_locale,
1105
+ entitlements: interaction.entitlements.map((entitlement) => this.entitlementFromRaw(entitlement)),
1106
+ authorizingIntegrationOwners: {
1107
+ "0": interaction.authorizing_integration_owners[0],
1108
+ "1": interaction.authorizing_integration_owners[1],
1109
+ },
1110
+ context: interaction.context,
1111
+ };
1112
+ }
1113
+ interactionToRaw(interaction) {
1114
+ return {
1115
+ id: interaction.id,
1116
+ application_id: interaction.applicationId,
1117
+ type: interaction.type,
1118
+ data: interaction.data !== undefined
1119
+ ? {
1120
+ id: interaction.data.id,
1121
+ name: interaction.data.name,
1122
+ type: interaction.data.type,
1123
+ resolved: interaction.data.resolved !== undefined
1124
+ ? this.resolvedDataToRaw(interaction.data.resolved)
1125
+ : undefined,
1126
+ options: interaction.data.options,
1127
+ guild_id: interaction.data.guildId,
1128
+ target_id: interaction.data.targetId,
1129
+ custom_id: interaction.data.customId,
1130
+ component_type: interaction.data.componentType,
1131
+ values: interaction.data.values,
1132
+ components: interaction.data.components?.map((component) => ({
1133
+ type: component.type,
1134
+ components: component.components?.map((c) => ({
1135
+ type: c.type,
1136
+ custom_id: c.customId,
1137
+ style: c.style,
1138
+ label: c.label,
1139
+ min_length: c.minLength,
1140
+ max_length: c.maxLength,
1141
+ required: c.required,
1142
+ value: c.value,
1143
+ placeholder: c.placeholder,
1144
+ })),
1145
+ })),
1146
+ }
1147
+ : undefined,
1148
+ guild: interaction.guild !== undefined
1149
+ ? {
1150
+ locale: interaction.guild.locale,
1151
+ id: interaction.guild.id,
1152
+ features: interaction.guild.features,
1153
+ }
1154
+ : undefined,
1155
+ guild_id: interaction.guildId,
1156
+ channel: interaction.channel !== undefined
1157
+ ? this.channelToRaw(interaction.channel)
1158
+ : undefined,
1159
+ channel_id: interaction.channelId,
1160
+ member: interaction.member !== undefined
1161
+ ? this.guildMemberToRaw(interaction.member)
1162
+ : undefined,
1163
+ user: interaction.user !== undefined
1164
+ ? this.userToRaw(interaction.user)
1165
+ : undefined,
1166
+ token: interaction.token,
1167
+ version: interaction.version,
1168
+ message: interaction.message !== undefined
1169
+ ? this.messageToRaw(interaction.message)
1170
+ : undefined,
1171
+ app_permissions: interaction.appPermissions,
1172
+ locale: interaction.locale,
1173
+ guild_locale: interaction.guildLocale,
1174
+ entitlements: interaction.entitlements.map((entitlement) => this.entitlementToRaw(entitlement)),
1175
+ authorizing_integration_owners: {
1176
+ "0": interaction.authorizingIntegrationOwners[0],
1177
+ "1": interaction.authorizingIntegrationOwners[1],
1178
+ },
1179
+ context: interaction.context,
1180
+ };
1181
+ }
1182
+ interactionMetadataFromRaw(interactionMetadata) {
1183
+ return {
1184
+ id: interactionMetadata.id,
1185
+ type: interactionMetadata.type,
1186
+ user: this.userFromRaw(interactionMetadata.user),
1187
+ authorizingIntegrationOwners: {
1188
+ "0": interactionMetadata.authorizing_integration_owners[0],
1189
+ "1": interactionMetadata.authorizing_integration_owners[1],
1190
+ },
1191
+ originalResponseMessageId: interactionMetadata.original_response_message_id,
1192
+ interactedMessageId: interactionMetadata.interacted_message_id,
1193
+ triggeringInteractionMetadata: interactionMetadata.triggering_interaction_metadata !== undefined
1194
+ ? this.interactionMetadataFromRaw(interactionMetadata.triggering_interaction_metadata)
1195
+ : undefined,
1196
+ };
1197
+ }
1198
+ interactionMetadataToRaw(interactionMetadata) {
1199
+ return {
1200
+ id: interactionMetadata.id,
1201
+ type: interactionMetadata.type,
1202
+ user: this.userToRaw(interactionMetadata.user),
1203
+ authorizing_integration_owners: {
1204
+ "0": interactionMetadata.authorizingIntegrationOwners[0],
1205
+ "1": interactionMetadata.authorizingIntegrationOwners[1],
1206
+ },
1207
+ original_response_message_id: interactionMetadata.originalResponseMessageId,
1208
+ interacted_message_id: interactionMetadata.interactedMessageId,
1209
+ triggering_interaction_metadata: interactionMetadata.triggeringInteractionMetadata !== undefined
1210
+ ? this.interactionMetadataToRaw(interactionMetadata.triggeringInteractionMetadata)
1211
+ : undefined,
1212
+ };
1213
+ }
1214
+ inviteFromRaw(invite) {
1215
+ return {
1216
+ type: invite.type,
1217
+ code: invite.code,
1218
+ guild: invite.guild !== undefined
1219
+ ? this.guildFromRaw(invite.guild)
1220
+ : undefined,
1221
+ channel: this.channelFromRaw(invite.channel),
1222
+ inviter: invite.inviter !== undefined
1223
+ ? this.userFromRaw(invite.inviter)
1224
+ : undefined,
1225
+ targetType: invite.target_type,
1226
+ targetUser: invite.target_user !== undefined
1227
+ ? this.userFromRaw(invite.target_user)
1228
+ : undefined,
1229
+ targetApplication: invite.target_application !== undefined
1230
+ ? this.applicationFromRaw(invite.target_application)
1231
+ : undefined,
1232
+ approximatePresenceCount: invite.approximate_presence_count,
1233
+ approximateMemberCount: invite.approximate_member_count,
1234
+ expiresAt: invite.expires_at,
1235
+ stageInstance: invite.stage_instance !== undefined
1236
+ ? {
1237
+ members: invite.stage_instance.members.map((guildMember) => this.guildMemberFromRaw(guildMember)),
1238
+ participantCount: invite.stage_instance.participant_count,
1239
+ speakerCount: invite.stage_instance.speaker_count,
1240
+ topic: invite.stage_instance.topic,
1241
+ }
1242
+ : undefined,
1243
+ guildScheduledEvent: invite.guild_scheduled_event !== undefined
1244
+ ? this.guildScheduledEventFromRaw(invite.guild_scheduled_event)
1245
+ : undefined,
1246
+ };
1247
+ }
1248
+ inviteToRaw(invite) {
1249
+ return {
1250
+ type: invite.type,
1251
+ code: invite.code,
1252
+ guild: invite.guild !== undefined ? this.guildToRaw(invite.guild) : undefined,
1253
+ channel: this.channelToRaw(invite.channel),
1254
+ inviter: invite.inviter !== undefined
1255
+ ? this.userToRaw(invite.inviter)
1256
+ : undefined,
1257
+ target_type: invite.targetType,
1258
+ target_user: invite.targetUser !== undefined
1259
+ ? this.userToRaw(invite.targetUser)
1260
+ : undefined,
1261
+ target_application: invite.targetApplication !== undefined
1262
+ ? this.applicationToRaw(invite.targetApplication)
1263
+ : undefined,
1264
+ approximate_presence_count: invite.approximatePresenceCount,
1265
+ approximate_member_count: invite.approximateMemberCount,
1266
+ expires_at: invite.expiresAt,
1267
+ stage_instance: invite.stageInstance !== undefined
1268
+ ? {
1269
+ members: invite.stageInstance.members.map((guildMember) => this.guildMemberToRaw(guildMember)),
1270
+ participant_count: invite.stageInstance.participantCount,
1271
+ speaker_count: invite.stageInstance.speakerCount,
1272
+ topic: invite.stageInstance.topic,
1273
+ }
1274
+ : undefined,
1275
+ guild_scheduled_event: invite.guildScheduledEvent !== undefined
1276
+ ? this.guildScheduledEventToRaw(invite.guildScheduledEvent)
1277
+ : undefined,
1278
+ };
1279
+ }
1280
+ messageComponentsFromRaw(components) {
1281
+ return components.map((component) => ({
1282
+ type: component.type,
1283
+ components: component.components.map((c) => {
1284
+ switch (c.type) {
1285
+ case constants_1.ComponentTypes.Button: {
1286
+ return {
1287
+ type: c.type,
1288
+ style: c.style,
1289
+ label: c.label,
1290
+ emoji: c.emoji !== undefined
1291
+ ? {
1292
+ name: c.emoji.name,
1293
+ id: c.emoji.id,
1294
+ animated: c.emoji.animated,
1295
+ }
1296
+ : undefined,
1297
+ customId: c.custom_id,
1298
+ url: c.url,
1299
+ disabled: c.disabled,
1300
+ };
1301
+ }
1302
+ case constants_1.ComponentTypes.TextInput: {
1303
+ return {
1304
+ type: c.type,
1305
+ customId: c.custom_id,
1306
+ style: c.style,
1307
+ label: c.label,
1308
+ minLength: c.min_length,
1309
+ maxLength: c.max_length,
1310
+ required: c.required,
1311
+ value: c.value,
1312
+ placeholder: c.placeholder,
1313
+ };
1314
+ }
1315
+ case constants_1.ComponentTypes.ChannelSelect: {
1316
+ return {
1317
+ type: c.type,
1318
+ customId: c.custom_id,
1319
+ channelTypes: c.channel_types,
1320
+ placeholder: c.placeholder,
1321
+ defaultValues: c.default_values,
1322
+ minValues: c.min_values,
1323
+ maxValues: c.max_values,
1324
+ disabled: c.disabled,
1325
+ };
1326
+ }
1327
+ case constants_1.ComponentTypes.StringSelect: {
1328
+ return {
1329
+ type: c.type,
1330
+ customId: c.custom_id,
1331
+ placeholder: c.placeholder,
1332
+ options: c.options?.map((option) => ({
1333
+ label: option.label,
1334
+ value: option.value,
1335
+ description: option.description,
1336
+ emoji: option.emoji !== undefined
1337
+ ? {
1338
+ name: option.emoji.name,
1339
+ id: option.emoji.id,
1340
+ animated: option.emoji.animated,
1341
+ }
1342
+ : undefined,
1343
+ default: option.default,
1344
+ })),
1345
+ minValues: c.min_values,
1346
+ maxValues: c.max_values,
1347
+ disabled: c.disabled,
1348
+ };
1349
+ }
1350
+ case constants_1.ComponentTypes.MentionableSelect:
1351
+ case constants_1.ComponentTypes.RoleSelect:
1352
+ case constants_1.ComponentTypes.UserSelect: {
1353
+ return {
1354
+ type: c.type,
1355
+ customId: c.custom_id,
1356
+ placeholder: c.placeholder,
1357
+ defaultValues: c.default_values,
1358
+ minValues: c.min_values,
1359
+ maxValues: c.max_values,
1360
+ disabled: c.disabled,
1361
+ };
1362
+ }
1363
+ }
1364
+ }),
1365
+ }));
1366
+ }
1367
+ messageComponentsToRaw(components) {
1368
+ return components.map((component) => ({
1369
+ type: component.type,
1370
+ components: component.components.map((c) => {
1371
+ switch (c.type) {
1372
+ case constants_1.ComponentTypes.Button: {
1373
+ return {
1374
+ type: c.type,
1375
+ style: c.style,
1376
+ label: c.label,
1377
+ emoji: c.emoji !== undefined
1378
+ ? {
1379
+ name: c.emoji.name,
1380
+ id: c.emoji.id,
1381
+ animated: c.emoji.animated,
1382
+ }
1383
+ : undefined,
1384
+ custom_id: c.customId,
1385
+ url: c.url,
1386
+ disabled: c.disabled,
1387
+ };
1388
+ }
1389
+ case constants_1.ComponentTypes.TextInput: {
1390
+ return {
1391
+ type: c.type,
1392
+ custom_id: c.customId,
1393
+ style: c.style,
1394
+ label: c.label,
1395
+ min_length: c.minLength,
1396
+ max_length: c.maxLength,
1397
+ required: c.required,
1398
+ value: c.value,
1399
+ placeholder: c.placeholder,
1400
+ };
1401
+ }
1402
+ case constants_1.ComponentTypes.ChannelSelect: {
1403
+ return {
1404
+ type: c.type,
1405
+ custom_id: c.customId,
1406
+ channel_types: c.channelTypes,
1407
+ placeholder: c.placeholder,
1408
+ default_values: c.defaultValues,
1409
+ min_values: c.minValues,
1410
+ max_values: c.maxValues,
1411
+ disabled: c.disabled,
1412
+ };
1413
+ }
1414
+ case constants_1.ComponentTypes.StringSelect: {
1415
+ return {
1416
+ type: c.type,
1417
+ custom_id: c.customId,
1418
+ placeholder: c.placeholder,
1419
+ options: c.options?.map((option) => ({
1420
+ label: option.label,
1421
+ value: option.value,
1422
+ description: option.description,
1423
+ emoji: option.emoji !== undefined
1424
+ ? {
1425
+ name: option.emoji.name,
1426
+ id: option.emoji.id,
1427
+ animated: option.emoji.animated,
1428
+ }
1429
+ : undefined,
1430
+ default: option.default,
1431
+ })),
1432
+ min_values: c.minValues,
1433
+ max_values: c.maxValues,
1434
+ disabled: c.disabled,
1435
+ };
1436
+ }
1437
+ case constants_1.ComponentTypes.MentionableSelect:
1438
+ case constants_1.ComponentTypes.RoleSelect:
1439
+ case constants_1.ComponentTypes.UserSelect: {
1440
+ return {
1441
+ type: c.type,
1442
+ custom_id: c.customId,
1443
+ placeholder: c.placeholder,
1444
+ default_values: c.defaultValues,
1445
+ min_values: c.minValues,
1446
+ max_values: c.maxValues,
1447
+ disabled: c.disabled,
1448
+ };
1449
+ }
1450
+ }
1451
+ }),
1452
+ }));
1453
+ }
1454
+ messageFromRaw(message) {
1455
+ return {
1456
+ id: message.id,
1457
+ channelId: message.channel_id,
1458
+ author: this.userFromRaw(message.author),
1459
+ content: message.content,
1460
+ timestamp: message.timestamp,
1461
+ editedTimestamp: message.edited_timestamp,
1462
+ tts: message.tts,
1463
+ mentionEveryone: message.mention_everyone,
1464
+ mentions: message.mentions.map((user) => this.userFromRaw(user)),
1465
+ mentionRoles: message.mention_roles,
1466
+ mentionChannels: message.mention_channels?.map((channelMention) => ({
1467
+ id: channelMention.id,
1468
+ guildId: channelMention.guild_id,
1469
+ type: channelMention.type,
1470
+ name: channelMention.name,
1471
+ })),
1472
+ attachments: message.attachments.map((attachment) => this.attachmentFromRaw(attachment)),
1473
+ embeds: message.embeds,
1474
+ reactions: message.reactions?.map((reaction) => ({
1475
+ count: reaction.count,
1476
+ countDetails: reaction.count_details,
1477
+ me: reaction.me,
1478
+ meBurst: reaction.me_burst,
1479
+ emoji: this.emojiFromRaw(reaction.emoji),
1480
+ burstColors: reaction.burst_colors,
1481
+ })),
1482
+ nonce: message.nonce,
1483
+ pinned: message.pinned,
1484
+ webhookId: message.webhook_id,
1485
+ type: message.type,
1486
+ activity: message.activity,
1487
+ application: message.application !== undefined
1488
+ ? this.applicationFromRaw(message.application)
1489
+ : undefined,
1490
+ applicationId: message.application_id,
1491
+ messageReference: message.message_reference !== undefined
1492
+ ? {
1493
+ messageId: message.message_reference.message_id,
1494
+ channelId: message.message_reference.channel_id,
1495
+ guildId: message.message_reference.guild_id,
1496
+ failIfNotExists: message.message_reference.fail_if_not_exists,
1497
+ }
1498
+ : undefined,
1499
+ flags: message.flags,
1500
+ referencedMessage: message.referenced_message !== undefined
1501
+ ? message.referenced_message !== null
1502
+ ? this.messageFromRaw(message.referenced_message)
1503
+ : null
1504
+ : undefined,
1505
+ interactionMetadata: message.interaction_metadata !== undefined
1506
+ ? this.interactionMetadataFromRaw(message.interaction_metadata)
1507
+ : undefined,
1508
+ interaction: message.interaction !== undefined
1509
+ ? {
1510
+ id: message.interaction.id,
1511
+ type: message.interaction.type,
1512
+ name: message.interaction.name,
1513
+ user: this.userFromRaw(message.interaction.user),
1514
+ member: message.interaction.member !== undefined
1515
+ ? this.guildMemberFromRaw(message.interaction.member)
1516
+ : undefined,
1517
+ }
1518
+ : undefined,
1519
+ thread: message.thread !== undefined
1520
+ ? this.channelFromRaw(message.thread)
1521
+ : undefined,
1522
+ components: message.components !== undefined
1523
+ ? this.messageComponentsFromRaw(message.components)
1524
+ : undefined,
1525
+ stickerItems: message.sticker_items?.map((stickerItem) => ({
1526
+ id: stickerItem.id,
1527
+ name: stickerItem.name,
1528
+ formatType: stickerItem.format_type,
1529
+ })),
1530
+ stickers: message.stickers?.map((sticker) => this.stickerFromRaw(sticker)),
1531
+ position: message.position,
1532
+ roleSubscriptionData: message.role_subscription_data !== undefined
1533
+ ? {
1534
+ roleSubscriptionListingId: message.role_subscription_data.role_subscription_listing_id,
1535
+ tierName: message.role_subscription_data.tier_name,
1536
+ totalMonthsSubscribed: message.role_subscription_data.total_months_subscribed,
1537
+ isRenewal: message.role_subscription_data.is_renewal,
1538
+ }
1539
+ : undefined,
1540
+ resolved: message.resolved !== undefined
1541
+ ? this.resolvedDataFromRaw(message.resolved)
1542
+ : undefined,
1543
+ poll: message.poll !== undefined ? this.pollFromRaw(message.poll) : undefined,
1544
+ call: message.call,
1545
+ };
1546
+ }
1547
+ messageToRaw(message) {
1548
+ return {
1549
+ id: message.id,
1550
+ channel_id: message.channelId,
1551
+ author: this.userToRaw(message.author),
1552
+ content: message.content,
1553
+ timestamp: message.timestamp,
1554
+ edited_timestamp: message.editedTimestamp,
1555
+ tts: message.tts,
1556
+ mention_everyone: message.mentionEveryone,
1557
+ mentions: message.mentions.map((user) => this.userToRaw(user)),
1558
+ mention_roles: message.mentionRoles,
1559
+ mention_channels: message.mentionChannels?.map((channelMention) => ({
1560
+ id: channelMention.id,
1561
+ guild_id: channelMention.guildId,
1562
+ type: channelMention.type,
1563
+ name: channelMention.name,
1564
+ })),
1565
+ attachments: message.attachments.map((attachment) => this.attachmentToRaw(attachment)),
1566
+ embeds: message.embeds,
1567
+ reactions: message.reactions?.map((reaction) => ({
1568
+ count: reaction.count,
1569
+ count_details: reaction.countDetails,
1570
+ me: reaction.me,
1571
+ me_burst: reaction.meBurst,
1572
+ emoji: this.emojiToRaw(reaction.emoji),
1573
+ burst_colors: reaction.burstColors,
1574
+ })),
1575
+ nonce: message.nonce,
1576
+ pinned: message.pinned,
1577
+ webhook_id: message.webhookId,
1578
+ type: message.type,
1579
+ activity: message.activity,
1580
+ application: message.application !== undefined
1581
+ ? this.applicationToRaw(message.application)
1582
+ : undefined,
1583
+ application_id: message.applicationId,
1584
+ message_reference: message.messageReference !== undefined
1585
+ ? {
1586
+ message_id: message.messageReference.messageId,
1587
+ channel_id: message.messageReference.channelId,
1588
+ guild_id: message.messageReference.guildId,
1589
+ fail_if_not_exists: message.messageReference.failIfNotExists,
1590
+ }
1591
+ : undefined,
1592
+ flags: message.flags,
1593
+ referenced_message: message.referencedMessage !== undefined
1594
+ ? message.referencedMessage !== null
1595
+ ? this.messageToRaw(message.referencedMessage)
1596
+ : null
1597
+ : undefined,
1598
+ interaction_metadata: message.interactionMetadata !== undefined
1599
+ ? this.interactionMetadataToRaw(message.interactionMetadata)
1600
+ : undefined,
1601
+ interaction: message.interaction !== undefined
1602
+ ? {
1603
+ id: message.interaction.id,
1604
+ type: message.interaction.type,
1605
+ name: message.interaction.name,
1606
+ user: this.userToRaw(message.interaction.user),
1607
+ member: message.interaction.member !== undefined
1608
+ ? this.guildMemberToRaw(message.interaction.member)
1609
+ : undefined,
1610
+ }
1611
+ : undefined,
1612
+ thread: message.thread !== undefined
1613
+ ? this.channelToRaw(message.thread)
1614
+ : undefined,
1615
+ components: message.components !== undefined
1616
+ ? this.messageComponentsToRaw(message.components)
1617
+ : undefined,
1618
+ sticker_items: message.stickerItems?.map((stickerItem) => ({
1619
+ id: stickerItem.id,
1620
+ name: stickerItem.name,
1621
+ format_type: stickerItem.formatType,
1622
+ })),
1623
+ stickers: message.stickers?.map((sticker) => this.stickerToRaw(sticker)),
1624
+ position: message.position,
1625
+ role_subscription_data: message.roleSubscriptionData !== undefined
1626
+ ? {
1627
+ role_subscription_listing_id: message.roleSubscriptionData.roleSubscriptionListingId,
1628
+ tier_name: message.roleSubscriptionData.tierName,
1629
+ total_months_subscribed: message.roleSubscriptionData.totalMonthsSubscribed,
1630
+ is_renewal: message.roleSubscriptionData.isRenewal,
1631
+ }
1632
+ : undefined,
1633
+ resolved: message.resolved !== undefined
1634
+ ? this.resolvedDataToRaw(message.resolved)
1635
+ : undefined,
1636
+ poll: message.poll !== undefined ? this.pollToRaw(message.poll) : undefined,
1637
+ call: message.call,
1638
+ };
1639
+ }
1640
+ partialApplicationCommandToRaw(applicationCommand) {
1641
+ return {
1642
+ id: applicationCommand.id,
1643
+ type: applicationCommand.type,
1644
+ application_id: applicationCommand.applicationId,
1645
+ guild_id: applicationCommand.guildId,
1646
+ name: applicationCommand.name,
1647
+ name_localizations: applicationCommand.nameLocalizations,
1648
+ description: applicationCommand.description,
1649
+ description_localizations: applicationCommand.descriptionLocalizations,
1650
+ options: applicationCommand.options?.map((option) => ({
1651
+ type: option.type,
1652
+ name: option.name,
1653
+ name_localizations: option.nameLocalizations,
1654
+ description: option.description,
1655
+ description_localizations: option.descriptionLocalizations,
1656
+ required: option.required,
1657
+ choices: option.choices?.map((choice) => ({
1658
+ name: choice.name,
1659
+ name_localizations: choice.nameLocalizations,
1660
+ value: choice.value,
1661
+ })),
1662
+ options: option.options?.map((o) => ({
1663
+ type: o.type,
1664
+ name: o.name,
1665
+ name_localizations: o.nameLocalizations,
1666
+ description: o.description,
1667
+ description_localizations: o.descriptionLocalizations,
1668
+ required: o.required,
1669
+ choices: o.choices?.map((choice) => ({
1670
+ name: choice.name,
1671
+ name_localizations: choice.nameLocalizations,
1672
+ value: choice.value,
1673
+ })),
1674
+ channel_types: o.channelTypes,
1675
+ min_value: o.minValue,
1676
+ max_value: o.maxValue,
1677
+ min_length: o.minLength,
1678
+ max_length: o.maxLength,
1679
+ autocomplete: o.autocomplete,
1680
+ })),
1681
+ channel_types: option.channelTypes,
1682
+ min_value: option.minValue,
1683
+ max_value: option.maxValue,
1684
+ min_length: option.minLength,
1685
+ max_length: option.maxLength,
1686
+ autocomplete: option.autocomplete,
1687
+ })),
1688
+ default_member_permissions: applicationCommand.defaultMemberPermissions,
1689
+ dm_permission: applicationCommand.dmPermission,
1690
+ default_permission: applicationCommand.defaultPermission,
1691
+ nsfw: applicationCommand.nsfw,
1692
+ version: applicationCommand.version,
1693
+ };
1694
+ }
1695
+ presenceFromRaw(presence) {
1696
+ return {
1697
+ user: this.userFromRaw(presence.user),
1698
+ guildId: presence.guild_id,
1699
+ status: presence.status,
1700
+ activities: presence.activities.map((activity) => ({
1701
+ name: activity.name,
1702
+ type: activity.type,
1703
+ url: activity.url,
1704
+ createdAt: activity.created_at,
1705
+ timestamps: activity.timestamps,
1706
+ applicationId: activity.application_id,
1707
+ details: activity.details,
1708
+ state: activity.state,
1709
+ party: activity.party,
1710
+ assets: {
1711
+ largeImage: activity.assets?.large_image,
1712
+ largeText: activity.assets?.large_text,
1713
+ smallImage: activity.assets?.small_image,
1714
+ smallText: activity.assets?.small_text,
1715
+ },
1716
+ secrets: activity.secrets,
1717
+ instance: activity.instance,
1718
+ flags: activity.flags,
1719
+ buttons: activity.buttons,
1720
+ })),
1721
+ clientStatus: presence.client_status,
1722
+ };
1723
+ }
1724
+ presenceToRaw(presence) {
1725
+ return {
1726
+ user: this.userToRaw(presence.user),
1727
+ guild_id: presence.guildId,
1728
+ status: presence.status,
1729
+ activities: presence.activities.map((activity) => ({
1730
+ name: activity.name,
1731
+ type: activity.type,
1732
+ url: activity.url,
1733
+ created_at: activity.createdAt,
1734
+ timestamps: activity.timestamps,
1735
+ application_id: activity.applicationId,
1736
+ details: activity.details,
1737
+ state: activity.state,
1738
+ party: activity.party,
1739
+ assets: {
1740
+ large_image: activity.assets?.largeImage,
1741
+ large_text: activity.assets?.largeText,
1742
+ small_image: activity.assets?.smallImage,
1743
+ small_text: activity.assets?.smallText,
1744
+ },
1745
+ secrets: activity.secrets,
1746
+ instance: activity.instance,
1747
+ flags: activity.flags,
1748
+ buttons: activity.buttons,
1749
+ })),
1750
+ client_status: presence.clientStatus,
1751
+ };
1752
+ }
1753
+ resolvedDataFromRaw(resolvedData) {
1754
+ let users = {};
1755
+ let members = {};
1756
+ let roles = {};
1757
+ let channels = {};
1758
+ let messages = {};
1759
+ let attachments = {};
1760
+ if (resolvedData.users !== undefined) {
1761
+ for (const [key, value] of Object.entries(resolvedData.users)) {
1762
+ users[key] = this.userFromRaw(value);
19
1763
  }
20
1764
  }
21
- else {
22
- return obj;
1765
+ if (resolvedData.members !== undefined) {
1766
+ for (const [key, value] of Object.entries(resolvedData.members)) {
1767
+ members[key] = this.guildMemberFromRaw(value);
1768
+ }
1769
+ }
1770
+ if (resolvedData.roles !== undefined) {
1771
+ for (const [key, value] of Object.entries(resolvedData.roles)) {
1772
+ roles[key] = this.roleFromRaw(value);
1773
+ }
23
1774
  }
1775
+ if (resolvedData.channels !== undefined) {
1776
+ for (const [key, value] of Object.entries(resolvedData.channels)) {
1777
+ channels[key] = this.channelFromRaw(value);
1778
+ }
1779
+ }
1780
+ if (resolvedData.messages !== undefined) {
1781
+ for (const [key, value] of Object.entries(resolvedData.messages)) {
1782
+ messages[key] = this.messageFromRaw(value);
1783
+ }
1784
+ }
1785
+ if (resolvedData.attachments !== undefined) {
1786
+ for (const [key, value] of Object.entries(resolvedData.attachments)) {
1787
+ attachments[key] = this.attachmentFromRaw(value);
1788
+ }
1789
+ }
1790
+ return {
1791
+ users,
1792
+ members,
1793
+ roles,
1794
+ channels,
1795
+ messages,
1796
+ attachments,
1797
+ };
24
1798
  }
25
- toSnakeCase(obj) {
26
- if (obj !== null && typeof obj === "object") {
27
- if (Array.isArray(obj)) {
28
- return obj.map((item) => this.toSnakeCase(item));
1799
+ resolvedDataToRaw(resolvedData) {
1800
+ let users = {};
1801
+ let members = {};
1802
+ let roles = {};
1803
+ let channels = {};
1804
+ let messages = {};
1805
+ let attachments = {};
1806
+ if (resolvedData.users !== undefined) {
1807
+ for (const [key, value] of Object.entries(resolvedData.users)) {
1808
+ users[key] = this.userToRaw(value);
29
1809
  }
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;
1810
+ }
1811
+ if (resolvedData.members !== undefined) {
1812
+ for (const [key, value] of Object.entries(resolvedData.members)) {
1813
+ members[key] = this.guildMemberToRaw(value);
39
1814
  }
40
1815
  }
41
- else {
42
- return obj;
1816
+ if (resolvedData.roles !== undefined) {
1817
+ for (const [key, value] of Object.entries(resolvedData.roles)) {
1818
+ roles[key] = this.roleToRaw(value);
1819
+ }
1820
+ }
1821
+ if (resolvedData.channels !== undefined) {
1822
+ for (const [key, value] of Object.entries(resolvedData.channels)) {
1823
+ channels[key] = this.channelToRaw(value);
1824
+ }
1825
+ }
1826
+ if (resolvedData.messages !== undefined) {
1827
+ for (const [key, value] of Object.entries(resolvedData.messages)) {
1828
+ messages[key] = this.messageToRaw(value);
1829
+ }
43
1830
  }
1831
+ if (resolvedData.attachments !== undefined) {
1832
+ for (const [key, value] of Object.entries(resolvedData.attachments)) {
1833
+ attachments[key] = this.attachmentToRaw(value);
1834
+ }
1835
+ }
1836
+ return {
1837
+ users,
1838
+ members,
1839
+ roles,
1840
+ channels,
1841
+ messages,
1842
+ attachments,
1843
+ };
1844
+ }
1845
+ pollFromRaw(poll) {
1846
+ return {
1847
+ question: poll.question,
1848
+ answers: poll.answers.map((answer) => ({
1849
+ answerId: answer.answer_id,
1850
+ pollMedia: answer.poll_media,
1851
+ })),
1852
+ expiry: poll.expiry,
1853
+ allowMultiselect: poll.allow_multiselect,
1854
+ layoutType: poll.layout_type,
1855
+ results: poll.results !== undefined
1856
+ ? {
1857
+ isFinalized: poll.results.is_finalized,
1858
+ answerCounts: poll.results.answer_counts.map((answerCount) => ({
1859
+ id: answerCount.id,
1860
+ count: answerCount.count,
1861
+ meVoted: answerCount.me_voted,
1862
+ })),
1863
+ }
1864
+ : undefined,
1865
+ };
1866
+ }
1867
+ pollToRaw(poll) {
1868
+ return {
1869
+ question: poll.question,
1870
+ answers: poll.answers.map((answer) => ({
1871
+ answer_id: answer.answerId,
1872
+ poll_media: answer.pollMedia,
1873
+ })),
1874
+ expiry: poll.expiry,
1875
+ allow_multiselect: poll.allowMultiselect,
1876
+ layout_type: poll.layoutType,
1877
+ results: poll.results !== undefined
1878
+ ? {
1879
+ is_finalized: poll.results.isFinalized,
1880
+ answer_counts: poll.results.answerCounts.map((answerCount) => ({
1881
+ id: answerCount.id,
1882
+ count: answerCount.count,
1883
+ me_voted: answerCount.meVoted,
1884
+ })),
1885
+ }
1886
+ : undefined,
1887
+ };
1888
+ }
1889
+ roleFromRaw(role) {
1890
+ return {
1891
+ id: role.id,
1892
+ name: role.name,
1893
+ color: role.color,
1894
+ hoist: role.hoist,
1895
+ icon: role.icon,
1896
+ unicodeEmoji: role.unicode_emoji,
1897
+ position: role.position,
1898
+ permissions: role.permissions,
1899
+ managed: role.managed,
1900
+ mentionable: role.mentionable,
1901
+ tags: role.tags !== undefined
1902
+ ? {
1903
+ botId: role.tags.bot_id,
1904
+ integrationId: role.tags.integration_id,
1905
+ premiumSubscriber: role.tags.premium_subscriber,
1906
+ subscriptionListingId: role.tags.subscription_listing_id,
1907
+ availableForPurchase: role.tags.available_for_purchase,
1908
+ guildConnections: role.tags.guild_connections,
1909
+ }
1910
+ : undefined,
1911
+ flags: role.flags,
1912
+ };
1913
+ }
1914
+ roleToRaw(role) {
1915
+ return {
1916
+ id: role.id,
1917
+ name: role.name,
1918
+ color: role.color,
1919
+ hoist: role.hoist,
1920
+ icon: role.icon,
1921
+ unicode_emoji: role.unicodeEmoji,
1922
+ position: role.position,
1923
+ permissions: role.permissions,
1924
+ managed: role.managed,
1925
+ mentionable: role.mentionable,
1926
+ tags: role.tags !== undefined
1927
+ ? {
1928
+ bot_id: role.tags.botId,
1929
+ integration_id: role.tags.integrationId,
1930
+ premium_subscriber: role.tags.premiumSubscriber,
1931
+ subscription_listing_id: role.tags.subscriptionListingId,
1932
+ available_for_purchase: role.tags.availableForPurchase,
1933
+ guild_connections: role.tags.guildConnections,
1934
+ }
1935
+ : undefined,
1936
+ flags: role.flags,
1937
+ };
1938
+ }
1939
+ skuFromRaw(sku) {
1940
+ return {
1941
+ id: sku.id,
1942
+ type: sku.type,
1943
+ dependentSkuId: sku.dependent_sku_id,
1944
+ applicationId: sku.application_id,
1945
+ manifestLabels: sku.manifest_labels,
1946
+ accessType: sku.access_type,
1947
+ name: sku.name,
1948
+ features: sku.features,
1949
+ releaseDate: sku.release_date,
1950
+ slug: sku.slug,
1951
+ flags: sku.flags,
1952
+ showAgeGate: sku.show_age_gate,
1953
+ };
1954
+ }
1955
+ skuToRaw(sku) {
1956
+ return {
1957
+ id: sku.id,
1958
+ type: sku.type,
1959
+ dependent_sku_id: sku.dependentSkuId,
1960
+ application_id: sku.applicationId,
1961
+ manifest_labels: sku.manifestLabels,
1962
+ access_type: sku.accessType,
1963
+ name: sku.name,
1964
+ features: sku.features,
1965
+ release_date: sku.releaseDate,
1966
+ slug: sku.slug,
1967
+ flags: sku.flags,
1968
+ show_age_gate: sku.showAgeGate,
1969
+ };
1970
+ }
1971
+ stageInstanceFromRaw(stageInstance) {
1972
+ return {
1973
+ id: stageInstance.id,
1974
+ guildId: stageInstance.guild_id,
1975
+ channelId: stageInstance.channel_id,
1976
+ topic: stageInstance.topic,
1977
+ privacyLevel: stageInstance.privacy_level,
1978
+ discoverableDisabled: stageInstance.discoverable_disabled,
1979
+ guildScheduledEventId: stageInstance.guild_scheduled_event_id,
1980
+ };
1981
+ }
1982
+ stageInstanceToRaw(stageInstance) {
1983
+ return {
1984
+ id: stageInstance.id,
1985
+ guild_id: stageInstance.guildId,
1986
+ channel_id: stageInstance.channelId,
1987
+ topic: stageInstance.topic,
1988
+ privacy_level: stageInstance.privacyLevel,
1989
+ discoverable_disabled: stageInstance.discoverableDisabled,
1990
+ guild_scheduled_event_id: stageInstance.guildScheduledEventId,
1991
+ };
1992
+ }
1993
+ stickerFromRaw(sticker) {
1994
+ return {
1995
+ id: sticker.id,
1996
+ packId: sticker.pack_id,
1997
+ name: sticker.name,
1998
+ description: sticker.description,
1999
+ tags: sticker.tags,
2000
+ asset: sticker.asset,
2001
+ type: sticker.type,
2002
+ formatType: sticker.format_type,
2003
+ available: sticker.available,
2004
+ guildId: sticker.id,
2005
+ user: sticker.user !== undefined ? this.userFromRaw(sticker.user) : undefined,
2006
+ sortValue: sticker.sort_value,
2007
+ };
2008
+ }
2009
+ stickerToRaw(sticker) {
2010
+ return {
2011
+ id: sticker.id,
2012
+ pack_id: sticker.packId,
2013
+ name: sticker.name,
2014
+ description: sticker.description,
2015
+ tags: sticker.tags,
2016
+ asset: sticker.asset,
2017
+ type: sticker.type,
2018
+ format_type: sticker.formatType,
2019
+ available: sticker.available,
2020
+ guild_id: sticker.id,
2021
+ user: sticker.user !== undefined ? this.userToRaw(sticker.user) : undefined,
2022
+ sort_value: sticker.sortValue,
2023
+ };
2024
+ }
2025
+ teamFromRaw(team) {
2026
+ return {
2027
+ icon: team.icon,
2028
+ id: team.id,
2029
+ members: team.members.map((teamMember) => ({
2030
+ membershipState: teamMember.membership_state,
2031
+ teamId: teamMember.team_id,
2032
+ user: this.userFromRaw(teamMember.user),
2033
+ role: teamMember.role,
2034
+ })),
2035
+ name: team.name,
2036
+ ownerUserId: team.owner_user_id,
2037
+ };
2038
+ }
2039
+ teamToRaw(team) {
2040
+ return {
2041
+ icon: team.icon,
2042
+ id: team.id,
2043
+ members: team.members.map((teamMember) => ({
2044
+ membership_state: teamMember.membershipState,
2045
+ team_id: teamMember.teamId,
2046
+ user: this.userToRaw(teamMember.user),
2047
+ role: teamMember.role,
2048
+ })),
2049
+ name: team.name,
2050
+ owner_user_id: team.ownerUserId,
2051
+ };
2052
+ }
2053
+ threadMemberFromRaw(threadMember) {
2054
+ return {
2055
+ id: threadMember.id,
2056
+ userId: threadMember.user_id,
2057
+ joinTimestamp: threadMember.join_timestamp,
2058
+ flags: threadMember.flags,
2059
+ member: threadMember.member !== undefined
2060
+ ? this.guildMemberFromRaw(threadMember.member)
2061
+ : undefined,
2062
+ };
2063
+ }
2064
+ threadMemberToRaw(threadMember) {
2065
+ return {
2066
+ id: threadMember.id,
2067
+ user_id: threadMember.userId,
2068
+ join_timestamp: threadMember.joinTimestamp,
2069
+ flags: threadMember.flags,
2070
+ member: threadMember.member !== undefined
2071
+ ? this.guildMemberToRaw(threadMember.member)
2072
+ : undefined,
2073
+ };
2074
+ }
2075
+ testEntitlementFromRaw(entitlement) {
2076
+ return {
2077
+ id: entitlement.id,
2078
+ skuId: entitlement.sku_id,
2079
+ applicationId: entitlement.application_id,
2080
+ userId: entitlement.user_id,
2081
+ promotionId: entitlement.promotion_id,
2082
+ type: entitlement.type,
2083
+ deleted: entitlement.deleted,
2084
+ giftCodeFlags: entitlement.gift_code_flags,
2085
+ consumed: entitlement.consumed,
2086
+ guildId: entitlement.guild_id,
2087
+ };
2088
+ }
2089
+ testEntitlementToRaw(entitlement) {
2090
+ return {
2091
+ id: entitlement.id,
2092
+ sku_id: entitlement.skuId,
2093
+ application_id: entitlement.applicationId,
2094
+ user_id: entitlement.userId,
2095
+ promotion_id: entitlement.promotionId,
2096
+ type: entitlement.type,
2097
+ deleted: entitlement.deleted,
2098
+ gift_code_flags: entitlement.giftCodeFlags,
2099
+ consumed: entitlement.consumed,
2100
+ guild_id: entitlement.guildId,
2101
+ };
2102
+ }
2103
+ userFromRaw(user) {
2104
+ return {
2105
+ id: user.id,
2106
+ username: user.username,
2107
+ discriminator: user.discriminator,
2108
+ globalName: user.global_name,
2109
+ avatar: user.avatar,
2110
+ bot: user.bot,
2111
+ system: user.system,
2112
+ mfaEnabled: user.mfa_enabled,
2113
+ banner: user.banner,
2114
+ accentColor: user.accent_color,
2115
+ locale: user.locale,
2116
+ verified: user.verified,
2117
+ email: user.email,
2118
+ flags: user.flags,
2119
+ premiumType: user.premium_type,
2120
+ publicFlags: user.public_flags,
2121
+ avatarDecoration: user.avatar_decoration,
2122
+ };
2123
+ }
2124
+ userToRaw(user) {
2125
+ return {
2126
+ id: user.id,
2127
+ username: user.username,
2128
+ discriminator: user.discriminator,
2129
+ global_name: user.globalName,
2130
+ avatar: user.avatar,
2131
+ bot: user.bot,
2132
+ system: user.system,
2133
+ mfa_enabled: user.mfaEnabled,
2134
+ banner: user.banner,
2135
+ accent_color: user.accentColor,
2136
+ locale: user.locale,
2137
+ verified: user.verified,
2138
+ email: user.email,
2139
+ flags: user.flags,
2140
+ premium_type: user.premiumType,
2141
+ public_flags: user.publicFlags,
2142
+ avatar_decoration: user.avatarDecoration,
2143
+ };
2144
+ }
2145
+ voiceStateFromRaw(voiceState) {
2146
+ return {
2147
+ guildId: voiceState.guild_id,
2148
+ channelId: voiceState.channel_id,
2149
+ userId: voiceState.user_id,
2150
+ member: voiceState.member !== undefined
2151
+ ? this.guildMemberFromRaw(voiceState.member)
2152
+ : undefined,
2153
+ sessionId: voiceState.session_id,
2154
+ deaf: voiceState.deaf,
2155
+ mute: voiceState.mute,
2156
+ selfDeaf: voiceState.self_deaf,
2157
+ selfMute: voiceState.self_mute,
2158
+ selfStream: voiceState.self_stream,
2159
+ selfVideo: voiceState.self_video,
2160
+ suppress: voiceState.suppress,
2161
+ requestToSpeakTimestamp: voiceState.request_to_speak_timestamp,
2162
+ };
2163
+ }
2164
+ voiceStateToRaw(voiceState) {
2165
+ return {
2166
+ guild_id: voiceState.guildId,
2167
+ channel_id: voiceState.channelId,
2168
+ user_id: voiceState.userId,
2169
+ member: voiceState.member !== undefined
2170
+ ? this.guildMemberToRaw(voiceState.member)
2171
+ : undefined,
2172
+ session_id: voiceState.sessionId,
2173
+ deaf: voiceState.deaf,
2174
+ mute: voiceState.mute,
2175
+ self_deaf: voiceState.selfDeaf,
2176
+ self_mute: voiceState.selfMute,
2177
+ self_stream: voiceState.selfStream,
2178
+ self_video: voiceState.selfVideo,
2179
+ suppress: voiceState.suppress,
2180
+ request_to_speak_timestamp: voiceState.requestToSpeakTimestamp,
2181
+ };
2182
+ }
2183
+ webhookFromRaw(webhook) {
2184
+ return {
2185
+ id: webhook.id,
2186
+ type: webhook.type,
2187
+ guildId: webhook.guild_id,
2188
+ channelId: webhook.channel_id,
2189
+ user: webhook.user !== undefined ? this.userFromRaw(webhook.user) : undefined,
2190
+ name: webhook.name,
2191
+ avatar: webhook.avatar,
2192
+ token: webhook.token,
2193
+ applicationId: webhook.application_id,
2194
+ sourceGuild: webhook.source_guild !== undefined
2195
+ ? this.guildFromRaw(webhook.source_guild)
2196
+ : undefined,
2197
+ sourceChannel: webhook.source_channel !== undefined
2198
+ ? this.channelFromRaw(webhook.source_channel)
2199
+ : undefined,
2200
+ url: webhook.url,
2201
+ };
2202
+ }
2203
+ webhookToRaw(webhook) {
2204
+ return {
2205
+ id: webhook.id,
2206
+ type: webhook.type,
2207
+ guild_id: webhook.guildId,
2208
+ channel_id: webhook.channelId,
2209
+ user: webhook.user !== undefined ? this.userToRaw(webhook.user) : undefined,
2210
+ name: webhook.name,
2211
+ avatar: webhook.avatar,
2212
+ token: webhook.token,
2213
+ application_id: webhook.applicationId,
2214
+ source_guild: webhook.sourceGuild !== undefined
2215
+ ? this.guildToRaw(webhook.sourceGuild)
2216
+ : undefined,
2217
+ source_channel: webhook.sourceChannel !== undefined
2218
+ ? this.channelToRaw(webhook.sourceChannel)
2219
+ : undefined,
2220
+ url: webhook.url,
2221
+ };
44
2222
  }
45
2223
  }
46
2224
  exports.Util = Util;