disgroove 1.2.9 → 1.3.0-dev.3af784e

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.
Files changed (108) hide show
  1. package/dist/Client.d.ts +43 -43
  2. package/dist/Client.js +76 -76
  3. package/dist/Client.js.map +1 -1
  4. package/dist/gateway/Shard.js +32 -36
  5. package/dist/gateway/Shard.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -1
  9. package/dist/rest/Endpoints.d.ts +1 -1
  10. package/dist/rest/Endpoints.js +3 -3
  11. package/dist/rest/RequestsManager.js +1 -1
  12. package/dist/rest/RequestsManager.js.map +1 -1
  13. package/dist/structures/Application.d.ts +72 -72
  14. package/dist/structures/Application.js +128 -155
  15. package/dist/structures/Application.js.map +1 -1
  16. package/dist/structures/ApplicationCommand.d.ts +4 -4
  17. package/dist/structures/ApplicationCommand.js +19 -19
  18. package/dist/structures/ApplicationCommand.js.map +1 -1
  19. package/dist/structures/AuditLog.d.ts +20 -0
  20. package/dist/structures/AuditLog.js +76 -0
  21. package/dist/structures/AuditLog.js.map +1 -0
  22. package/dist/structures/AutoModerationRule.d.ts +7 -7
  23. package/dist/structures/AutoModerationRule.js +7 -7
  24. package/dist/structures/AutoModerationRule.js.map +1 -1
  25. package/dist/structures/Channel.d.ts +134 -134
  26. package/dist/structures/Channel.js +263 -263
  27. package/dist/structures/Channel.js.map +1 -1
  28. package/dist/structures/ClientApplication.d.ts +324 -0
  29. package/dist/structures/ClientApplication.js +241 -0
  30. package/dist/structures/ClientApplication.js.map +1 -0
  31. package/dist/structures/Emoji.d.ts +2 -2
  32. package/dist/structures/Emoji.js +9 -9
  33. package/dist/structures/Emoji.js.map +1 -1
  34. package/dist/structures/Entitlement.d.ts +24 -0
  35. package/dist/structures/Entitlement.js +68 -0
  36. package/dist/structures/Entitlement.js.map +1 -0
  37. package/dist/structures/Guild.d.ts +311 -311
  38. package/dist/structures/Guild.js +615 -661
  39. package/dist/structures/Guild.js.map +1 -1
  40. package/dist/structures/GuildMember.d.ts +10 -10
  41. package/dist/structures/GuildMember.js +30 -30
  42. package/dist/structures/GuildMember.js.map +1 -1
  43. package/dist/structures/GuildScheduledEvent.d.ts +2 -2
  44. package/dist/structures/GuildScheduledEvent.js +7 -7
  45. package/dist/structures/GuildScheduledEvent.js.map +1 -1
  46. package/dist/structures/GuildTemplate.d.ts +4 -4
  47. package/dist/structures/GuildTemplate.js +7 -9
  48. package/dist/structures/GuildTemplate.js.map +1 -1
  49. package/dist/structures/Integration.d.ts +1 -1
  50. package/dist/structures/Integration.js +2 -2
  51. package/dist/structures/Integration.js.map +1 -1
  52. package/dist/structures/Interaction.d.ts +27 -42
  53. package/dist/structures/Interaction.js +97 -130
  54. package/dist/structures/Interaction.js.map +1 -1
  55. package/dist/structures/Invite.d.ts +2 -1
  56. package/dist/structures/Invite.js +1 -1
  57. package/dist/structures/Invite.js.map +1 -1
  58. package/dist/structures/Message.d.ts +23 -20
  59. package/dist/structures/Message.js +71 -206
  60. package/dist/structures/Message.js.map +1 -1
  61. package/dist/structures/PartialApplication.d.ts +70 -70
  62. package/dist/structures/PartialApplication.js +128 -155
  63. package/dist/structures/PartialApplication.js.map +1 -1
  64. package/dist/structures/Role.d.ts +2 -2
  65. package/dist/structures/Role.js +7 -7
  66. package/dist/structures/Role.js.map +1 -1
  67. package/dist/structures/SKU.d.ts +23 -0
  68. package/dist/structures/SKU.js +63 -0
  69. package/dist/structures/SKU.js.map +1 -0
  70. package/dist/structures/StageInstance.d.ts +3 -3
  71. package/dist/structures/StageInstance.js +7 -7
  72. package/dist/structures/StageInstance.js.map +1 -1
  73. package/dist/structures/Sticker.d.ts +2 -2
  74. package/dist/structures/Sticker.js +9 -9
  75. package/dist/structures/Sticker.js.map +1 -1
  76. package/dist/structures/Team.js +2 -2
  77. package/dist/structures/Team.js.map +1 -1
  78. package/dist/structures/TestEntitlement.d.ts +23 -0
  79. package/dist/structures/TestEntitlement.js +61 -0
  80. package/dist/structures/TestEntitlement.js.map +1 -0
  81. package/dist/structures/UnavailableGuild.d.ts +2 -487
  82. package/dist/structures/UnavailableGuild.js +1 -917
  83. package/dist/structures/UnavailableGuild.js.map +1 -1
  84. package/dist/structures/User.d.ts +13 -13
  85. package/dist/structures/User.js +35 -34
  86. package/dist/structures/User.js.map +1 -1
  87. package/dist/structures/Webhook.d.ts +26 -26
  88. package/dist/structures/Webhook.js +116 -148
  89. package/dist/structures/Webhook.js.map +1 -1
  90. package/dist/structures/index.d.ts +5 -1
  91. package/dist/structures/index.js +5 -1
  92. package/dist/structures/index.js.map +1 -1
  93. package/dist/types/application.d.ts +3 -3
  94. package/dist/types/auto-moderation.d.ts +3 -3
  95. package/dist/types/channel.d.ts +36 -21
  96. package/dist/types/gateway-events.d.ts +12 -12
  97. package/dist/types/guild.d.ts +5 -5
  98. package/dist/types/interaction.d.ts +57 -40
  99. package/dist/types/invite.d.ts +3 -2
  100. package/dist/types/message-components.d.ts +4 -4
  101. package/dist/types/sku.d.ts +1 -1
  102. package/dist/types/stage-instance.d.ts +3 -2
  103. package/dist/types/team.d.ts +1 -1
  104. package/dist/types/user.d.ts +3 -3
  105. package/dist/utils/Util.d.ts +11 -482
  106. package/dist/utils/Util.js +329 -151
  107. package/dist/utils/Util.js.map +1 -1
  108. package/package.json +1 -1
@@ -2,8 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.UnavailableGuild = void 0;
4
4
  const _1 = require(".");
5
- const rest_1 = require("../rest");
6
- const undici_1 = require("undici");
7
5
  /** https://discord.com/developers/docs/resources/guild */
8
6
  class UnavailableGuild extends _1.Base {
9
7
  raw;
@@ -13,926 +11,12 @@ class UnavailableGuild extends _1.Base {
13
11
  this.raw = data;
14
12
  this.unavailable = data.unavailable;
15
13
  }
16
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */
17
- async getApplicationCommands(applicationId, options) {
18
- return this.client.rest
19
- .get(rest_1.Endpoints.applicationGuildCommands(applicationId, this.id), {
20
- query: {
21
- with_localizations: options?.withLocalizations,
22
- },
23
- })
24
- .then((response) => response.map((data) => new _1.ApplicationCommand(data, this.client)));
25
- }
26
- /** https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */
27
- async createApplicationCommand(applicationId, options) {
28
- return new _1.ApplicationCommand(await this.client.rest.post(rest_1.Endpoints.applicationGuildCommands(applicationId, this.id), {
29
- json: this.client.util.applicationCommandToRaw(options),
30
- }), this.client);
31
- }
32
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command */
33
- async getApplicationCommand(applicationId, commandId) {
34
- return new _1.ApplicationCommand(await this.client.rest.get(rest_1.Endpoints.applicationGuildCommand(applicationId, this.id, commandId)), this.client);
35
- }
36
- /** https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */
37
- async editApplicationCommand(applicationId, commandId, options) {
38
- return new _1.ApplicationCommand(await this.client.rest.patch(rest_1.Endpoints.applicationGuildCommand(applicationId, this.id, commandId), {
39
- json: this.client.util.applicationCommandToRaw(options),
40
- }), this.client);
41
- }
42
- /** https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command */
43
- deleteApplicationCommand(applicationId, commandId) {
44
- this.client.rest.delete(rest_1.Endpoints.applicationGuildCommand(applicationId, this.id, commandId));
45
- }
46
- /** https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */
47
- async bulkOverwriteApplicationCommands(applicationId, commands) {
48
- return this.client.rest
49
- .put(rest_1.Endpoints.applicationGuildCommands(applicationId, this.id), {
50
- json: commands.map((command) => this.client.util.applicationCommandToRaw(command)),
51
- })
52
- .then((response) => response.map((data) => new _1.ApplicationCommand(data, this.client)));
53
- }
54
- /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
55
- async getApplicationCommandsPermissions(applicationId) {
56
- return this.client.rest
57
- .get(rest_1.Endpoints.guildApplicationCommandsPermissions(applicationId, this.id))
58
- .then((response) => response.map((permissions) => ({
59
- id: permissions.id,
60
- applicationId: permissions.application_id,
61
- guildId: permissions.guild_id,
62
- permissions: permissions.permissions.map((permission) => ({
63
- id: permission.id,
64
- type: permission.type,
65
- permission: permission.permission,
66
- })),
67
- })));
68
- }
69
- /** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
70
- async getApplicationCommandPermissions(applicationId, commandId) {
71
- return this.client.rest
72
- .get(rest_1.Endpoints.applicationCommandPermissions(applicationId, this.id, commandId))
73
- .then((response) => response.map((permissions) => ({
74
- id: permissions.id,
75
- applicationId: permissions.application_id,
76
- guildId: permissions.guild_id,
77
- permissions: permissions.permissions.map((permission) => ({
78
- id: permission.id,
79
- type: permission.type,
80
- permission: permission.permission,
81
- })),
82
- })));
83
- }
84
- /** https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log */
85
- async getAuditLog(options) {
86
- return this.client.rest
87
- .get(rest_1.Endpoints.guildAuditLog(this.id), {
88
- query: {
89
- user_id: options?.userId,
90
- action_type: options?.actionType,
91
- before: options?.before,
92
- after: options?.after,
93
- limit: options?.limit,
94
- },
95
- })
96
- .then((response) => ({
97
- applicationCommands: response.application_commands.map((applicationCommand) => new _1.ApplicationCommand(applicationCommand, this.client)),
98
- auditLogEntries: response.audit_log_entries.map((auditLogEntry) => ({
99
- targetId: auditLogEntry.target_id,
100
- changes: auditLogEntry.changes?.map((change) => ({
101
- newValue: change.new_value,
102
- oldValue: change.old_value,
103
- key: change.key,
104
- })),
105
- userId: auditLogEntry.user_id,
106
- id: auditLogEntry.id,
107
- actionType: auditLogEntry.action_type,
108
- options: auditLogEntry.options !== undefined
109
- ? {
110
- applicationId: auditLogEntry.options.application_id,
111
- autoModerationRuleName: auditLogEntry.options.auto_moderation_rule_name,
112
- autoModerationRuleTriggerType: auditLogEntry.options.auto_moderation_rule_trigger_type,
113
- channelId: auditLogEntry.options.channel_id,
114
- count: auditLogEntry.options.count,
115
- deleteMemberDays: auditLogEntry.options.delete_member_days,
116
- id: auditLogEntry.options.id,
117
- membersRemoved: auditLogEntry.options.members_removed,
118
- messageId: auditLogEntry.options.message_id,
119
- roleName: auditLogEntry.options.role_name,
120
- type: auditLogEntry.options.type,
121
- integrationType: auditLogEntry.options.integration_type,
122
- }
123
- : undefined,
124
- reason: auditLogEntry.reason,
125
- })),
126
- autoModerationRules: response.auto_moderation_rules.map((autoModerationRule) => new _1.AutoModerationRule(autoModerationRule, this.client)),
127
- guildScheduledEvents: response.guild_scheduled_events.map((guildScheduledEvent) => new _1.GuildScheduledEvent(guildScheduledEvent, this.client)),
128
- integrations: response.integrations.map((integration) => new _1.Integration(integration, this.client)),
129
- threads: response.threads.map((thread) => new _1.Channel(thread, this.client)),
130
- users: response.users.map((user) => new _1.User(user, this.client)),
131
- webhooks: response.webhooks.map((webhook) => new _1.Webhook(webhook, this.client)),
132
- }));
133
- }
134
- /** https://discord.com/developers/docs/resources/auto-moderation#list-auto-moderation-rules-for-guild */
135
- async getAutoModerationRules() {
136
- return this.client.rest
137
- .get(rest_1.Endpoints.guildAutoModerationRules(this.id))
138
- .then((response) => response.map((data) => new _1.AutoModerationRule(data, this.client)));
139
- }
140
- /** https://discord.com/developers/docs/resources/auto-moderation#get-auto-moderation-rule */
141
- async getAutoModerationRule(ruleId) {
142
- return new _1.AutoModerationRule(await this.client.rest.get(rest_1.Endpoints.guildAutoModerationRule(this.id, ruleId)), this.client);
143
- }
144
- /** https://discord.com/developers/docs/resources/auto-moderation#create-auto-moderation-rule */
145
- async createAutoModerationRule(options, reason) {
146
- return new _1.AutoModerationRule(await this.client.rest.post(rest_1.Endpoints.guildAutoModerationRules(this.id), {
147
- json: {
148
- name: options.name,
149
- event_type: options.eventType,
150
- trigger_type: options.triggerType,
151
- trigger_metadata: options.triggerMetadata,
152
- actions: options.actions.map((action) => ({
153
- type: action.type,
154
- metadata: {
155
- channel_id: action.metadata.channelId,
156
- duration_seconds: action.metadata.durationSeconds,
157
- custom_message: action.metadata.customMessage,
158
- },
159
- })),
160
- enabled: options.enabled,
161
- exempt_roles: options.exemptRoles,
162
- exempt_channels: options.exemptChannels,
163
- },
164
- reason,
165
- }), this.client);
166
- }
167
- /** https://discord.com/developers/docs/resources/auto-moderation#modify-auto-moderation-rule */
168
- async editAutoModerationRule(ruleId, options, reason) {
169
- return new _1.AutoModerationRule(await this.client.rest.patch(rest_1.Endpoints.guildAutoModerationRule(this.id, ruleId), {
170
- json: {
171
- name: options.name,
172
- event_type: options.eventType,
173
- trigger_type: options.triggerType,
174
- trigger_metadata: options.triggerMetadata,
175
- actions: options.actions?.map((action) => ({
176
- type: action.type,
177
- metadata: {
178
- channel_id: action.metadata.channelId,
179
- duration_seconds: action.metadata.durationSeconds,
180
- custom_message: action.metadata.customMessage,
181
- },
182
- })),
183
- enabled: options.enabled,
184
- exempt_roles: options.exemptRoles,
185
- exempt_channels: options.exemptChannels,
186
- },
187
- reason,
188
- }), this.client);
189
- }
190
- /** https://discord.com/developers/docs/resources/auto-moderation#delete-auto-moderation-rule */
191
- deleteAutoModerationRule(ruleId, reason) {
192
- this.client.rest.delete(rest_1.Endpoints.guildAutoModerationRule(this.id, ruleId), {
193
- reason,
194
- });
195
- }
196
- /** https://discord.com/developers/docs/resources/emoji#list-guild-emojis */
197
- async getEmojis() {
198
- return this.client.rest
199
- .get(rest_1.Endpoints.guildEmojis(this.id))
200
- .then((response) => response.map((data) => new _1.Emoji(data, this.client)));
201
- }
202
- /** https://discord.com/developers/docs/resources/emoji#get-guild-emoji */
203
- async getEmoji(emojiId) {
204
- return new _1.Emoji(await this.client.rest.get(rest_1.Endpoints.guildEmoji(this.id, emojiId)), this.client);
205
- }
206
- /** https://discord.com/developers/docs/resources/emoji#create-guild-emoji */
207
- async createEmoji(options, reason) {
208
- return new _1.Emoji(await this.client.rest.post(rest_1.Endpoints.guildEmojis(this.id), {
209
- json: {
210
- name: options.name,
211
- image: options.image,
212
- roles: options.roles,
213
- },
214
- reason,
215
- }), this.client);
216
- }
217
- /** https://discord.com/developers/docs/resources/emoji#modify-guild-emoji */
218
- async editEmoji(emojiId, options, reason) {
219
- return new _1.Emoji(await this.client.rest.patch(rest_1.Endpoints.guildEmoji(this.id, emojiId), {
220
- json: {
221
- name: options.name,
222
- roles: options.roles,
223
- },
224
- reason,
225
- }), this.client);
226
- }
227
- /** https://discord.com/developers/docs/resources/emoji#delete-guild-emoji */
228
- deleteEmoji(emojiId, reason) {
229
- this.client.rest.delete(rest_1.Endpoints.guildEmoji(this.id, emojiId), {
230
- reason,
231
- });
232
- }
233
- /** https://discord.com/developers/docs/resources/guild#get-guild-preview */
234
- async getPreview() {
235
- return this.client.rest
236
- .get(rest_1.Endpoints.guildPreview(this.id))
237
- .then((response) => ({
238
- id: response.id,
239
- name: response.name,
240
- icon: response.icon,
241
- splash: response.splash,
242
- discoverySplash: response.discovery_splash,
243
- emojis: response.emojis.map((emoji) => new _1.Emoji(emoji, this.client)),
244
- features: response.features,
245
- approximateMemberCount: response.approximate_member_count,
246
- approximatePresenceCount: response.approximate_presence_count,
247
- description: response.description,
248
- stickers: response.stickers?.map((sticker) => ({
249
- id: sticker.id,
250
- packId: sticker.pack_id,
251
- name: sticker.name,
252
- description: sticker.description,
253
- tags: sticker.tags,
254
- asset: sticker.asset,
255
- type: sticker.type,
256
- formatType: sticker.format_type,
257
- available: sticker.available,
258
- guildId: sticker.guild_id,
259
- user: sticker.user !== undefined
260
- ? new _1.User(sticker.user, this.client)
261
- : undefined,
262
- sortValue: sticker.sort_value,
263
- })),
264
- }));
265
- }
266
- /** https://discord.com/developers/docs/resources/guild#modify-guild */
267
- async edit(options, reason) {
268
- return new _1.Guild(await this.client.rest.patch(rest_1.Endpoints.guild(this.id), {
269
- json: {
270
- name: options.name,
271
- region: options.region,
272
- verification_level: options.verificationLevel,
273
- default_message_notifications: options.defaultMessageNotifications,
274
- explicit_content_filter: options.explicitContentFilter,
275
- afk_channel_id: options.afkChannelId,
276
- afk_timeout: options.afkTimeout,
277
- icon: options.icon,
278
- owner_id: options.ownerId,
279
- splash: options.splash,
280
- discovery_splash: options.discoverySplash,
281
- banner: options.banner,
282
- system_channel_id: options.systemChannelId,
283
- system_channel_flags: options.systemChannelFlags,
284
- rules_channel_id: options.rulesChannelId,
285
- public_updates_channel_id: options.publicUpdatesChannelId,
286
- preferred_locale: options.preferredLocale,
287
- features: options.features,
288
- description: options.description,
289
- premium_progress_bar_enabled: options.premiumProgressBarEnabled,
290
- safety_alerts_channel_id: options.safetyAlertsChannelId,
291
- },
292
- reason,
293
- }), this.client);
294
- }
295
- /** https://discord.com/developers/docs/resources/guild#delete-guild */
296
- delete() {
297
- this.client.rest.delete(rest_1.Endpoints.guild(this.id));
298
- }
299
- /** https://discord.com/developers/docs/resources/guild#get-guild-channels */
300
- async getChannels() {
301
- return this.client.rest
302
- .get(rest_1.Endpoints.guildChannels(this.id))
303
- .then((response) => response.map((data) => new _1.Channel(data, this.client)));
304
- }
305
- /** https://discord.com/developers/docs/resources/guild#create-guild-channel */
306
- async createChannel(options, reason) {
307
- return new _1.Channel(await this.client.rest.post(rest_1.Endpoints.guildChannels(this.id), {
308
- json: {
309
- name: options.name,
310
- type: options.type,
311
- topic: options.topic,
312
- bitrate: options.bitrate,
313
- user_limit: options.userLimit,
314
- rate_limit_per_user: options.rateLimitPerUser,
315
- position: options.position,
316
- permission_overwrites: options.permissionOverwrites,
317
- parent_id: options.parentId,
318
- nsfw: options.nsfw,
319
- rtc_region: options.rtcRegion,
320
- video_quality_mode: options.videoQualityMode,
321
- default_auto_archive_duration: options.defaultAutoArchiveDuration,
322
- default_reaction_emoji: {
323
- emojiId: options.defaultReactionEmoji?.emojiId,
324
- emojiName: options.defaultReactionEmoji?.emojiName,
325
- },
326
- available_tags: options.availableTags,
327
- default_sort_order: options.defaultSortOrder,
328
- default_forum_layout: options.defaultForumLayout,
329
- default_thread_rate_limit_per_user: options.defaultThreadRateLimitPerUser,
330
- },
331
- reason,
332
- }), this.client);
333
- }
334
- /** https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions */
335
- editChannelPositions(options) {
336
- this.client.rest.patch(rest_1.Endpoints.guildChannels(this.id), {
337
- json: options.map((data) => ({
338
- id: data.id,
339
- position: data.position,
340
- lock_permissions: data.lockPermissions,
341
- parent_id: data.parentId,
342
- })),
343
- });
344
- }
345
- /** https://discord.com/developers/docs/resources/guild#list-active-guild-threads */
346
- async getActiveThreads() {
347
- return this.client.rest
348
- .get(rest_1.Endpoints.guildActiveThreads(this.id))
349
- .then((response) => response.map((data) => ({
350
- threads: data.threads.map((data) => new _1.Channel(data, this.client)),
351
- members: data.members.map((data) => ({
352
- id: data.id,
353
- userId: data.user_id,
354
- joinTimestamp: data.join_timestamp,
355
- flags: data.flags,
356
- member: data.member !== undefined
357
- ? new _1.GuildMember(data.member, this.client)
358
- : undefined,
359
- })),
360
- })));
361
- }
362
- /** https://discord.com/developers/docs/resources/guild#get-guild-member */
363
- async getMember(userId) {
364
- return new _1.GuildMember(await this.client.rest.get(rest_1.Endpoints.guildMember(this.id, userId)), this.client);
365
- }
366
- /** https://discord.com/developers/docs/resources/guild#list-guild-members */
367
- async getMembers() {
368
- return this.client.rest
369
- .get(rest_1.Endpoints.guildMembers(this.id))
370
- .then((response) => response.map((data) => new _1.GuildMember(data, this.client)));
371
- }
372
- /** https://discord.com/developers/docs/resources/guild#search-guild-members */
373
- async searchMembers(options) {
374
- return this.client.rest
375
- .get(rest_1.Endpoints.guildMembersSearch(this.id), {
376
- query: {
377
- query: options.query,
378
- limit: options.limit,
379
- },
380
- })
381
- .then((response) => response.map((data) => new _1.GuildMember(data, this.client)));
382
- }
383
- /** https://discord.com/developers/docs/resources/guild#add-guild-member */
384
- async addMember(userId, options) {
385
- return this.client.rest
386
- .put(rest_1.Endpoints.guildMember(this.id, userId), {
387
- json: {
388
- access_token: options.accessToken,
389
- nick: options.nick,
390
- roles: options.roles,
391
- mute: options.mute,
392
- deaf: options.deaf,
393
- },
394
- })
395
- .then((response) => {
396
- if (response !== null) {
397
- return new _1.GuildMember(response, this.client);
398
- }
399
- else {
400
- return null;
401
- }
402
- });
403
- }
404
- /** https://discord.com/developers/docs/resources/guild#modify-guild-member */
405
- async editMember(userId, options, reason) {
406
- return new _1.GuildMember(await this.client.rest.patch(rest_1.Endpoints.guildMember(this.id, userId), {
407
- json: {
408
- nick: options.nick,
409
- roles: options.roles,
410
- mute: options.mute,
411
- deaf: options.deaf,
412
- channel_id: options.channelId,
413
- communication_disabled_until: options.communicationDisabledUntil,
414
- flags: options.flags,
415
- },
416
- reason,
417
- }), this.client);
418
- }
419
- /** https://discord.com/developers/docs/resources/guild#modify-current-member */
420
- async editCurrentMember(options, reason) {
421
- return new _1.GuildMember(await this.client.rest.patch(rest_1.Endpoints.guildMember(this.id), {
422
- json: {
423
- nick: options.nick,
424
- },
425
- reason,
426
- }), this.client);
427
- }
428
- /** https://discord.com/developers/docs/resources/guild#add-guild-member-role */
429
- addMemberRole(userId, roleId, reason) {
430
- this.client.rest.put(rest_1.Endpoints.guildMemberRole(this.id, userId, roleId), {
431
- reason,
432
- });
433
- }
434
- /** https://discord.com/developers/docs/resources/guild#remove-guild-member-role */
435
- removeMemberRole(userId, roleId, reason) {
436
- this.client.rest.delete(rest_1.Endpoints.guildMemberRole(this.id, userId, roleId), {
437
- reason,
438
- });
439
- }
440
- /** https://discord.com/developers/docs/resources/guild#remove-guild-member-role */
441
- removeMember(userId, reason) {
442
- this.client.rest.delete(rest_1.Endpoints.guildMember(this.id, userId), {
443
- reason,
444
- });
445
- }
446
- /** https://discord.com/developers/docs/resources/guild#get-guild-bans */
447
- async getBans(options) {
448
- return this.client.rest
449
- .get(rest_1.Endpoints.guildBans(this.id), {
450
- query: {
451
- limit: options?.limit,
452
- before: options?.before,
453
- after: options?.after,
454
- },
455
- })
456
- .then((response) => response.map((data) => ({
457
- reason: data.reason,
458
- user: new _1.User(data.user, this.client),
459
- })));
460
- }
461
- /** https://discord.com/developers/docs/resources/guild#get-guild-ban */
462
- async getBan(userId) {
463
- return this.client.rest
464
- .get(rest_1.Endpoints.guildBan(this.id, userId))
465
- .then((response) => ({
466
- reason: response.reason,
467
- user: new _1.User(response.user, this.client),
468
- }));
469
- }
470
- /** https://discord.com/developers/docs/resources/guild#create-guild-ban */
471
- createBan(userId, options, reason) {
472
- this.client.rest.put(rest_1.Endpoints.guildBan(this.id, userId), {
473
- json: {
474
- delete_message_days: options?.deleteMessageDays,
475
- delete_message_seconds: options?.deleteMessageSeconds,
476
- },
477
- reason,
478
- });
479
- }
480
- /** https://discord.com/developers/docs/resources/guild#remove-guild-ban */
481
- removeBan(userId, reason) {
482
- this.client.rest.delete(rest_1.Endpoints.guildBan(this.id, userId), {
483
- reason,
484
- });
485
- }
486
- /** https://discord.com/developers/docs/resources/guild#get-guild-roles */
487
- async getRoles() {
488
- return this.client.rest
489
- .get(rest_1.Endpoints.guildRoles(this.id))
490
- .then((response) => response.map((data) => new _1.Role(data, this.client)));
491
- }
492
- /** https://discord.com/developers/docs/resources/guild#create-guild-role */
493
- async createRole(options, reason) {
494
- return new _1.Role(await this.client.rest.post(rest_1.Endpoints.guildRoles(this.id), {
495
- json: {
496
- name: options.name,
497
- permissions: options.permissions,
498
- color: options.color,
499
- hoist: options.hoist,
500
- icon: options.icon,
501
- unicode_emoji: options.unicodeEmoji,
502
- mentionable: options.mentionable,
503
- },
504
- reason,
505
- }), this.client);
506
- }
507
- /** https://discord.com/developers/docs/resources/guild#modify-guild-role-positions */
508
- async editRolePositions(options) {
509
- return this.client.rest
510
- .patch(rest_1.Endpoints.guildRoles(this.id), {
511
- json: options.map((data) => ({
512
- id: data.id,
513
- position: data.position,
514
- })),
515
- })
516
- .then((response) => response.map((data) => new _1.Role(data, this.client)));
517
- }
518
- /** https://discord.com/developers/docs/resources/guild#modify-guild-role */
519
- async editRole(roleId, options, reason) {
520
- return new _1.Role(await this.client.rest.patch(rest_1.Endpoints.guildRole(this.id, roleId), {
521
- json: {
522
- name: options?.name,
523
- permissions: options?.permissions,
524
- color: options?.color,
525
- hoist: options?.hoist,
526
- icon: options?.icon,
527
- unicode_emoji: options?.unicodeEmoji,
528
- mentionable: options?.mentionable,
529
- },
530
- reason,
531
- }), this.client);
532
- }
533
- /** https://discord.com/developers/docs/resources/guild#modify-guild-mfa-level */
534
- async editMFALevel(options, reason) {
535
- return this.client.rest.post(rest_1.Endpoints.guildMFA(this.id), {
536
- json: {
537
- level: options.level,
538
- },
539
- reason,
540
- });
541
- }
542
- /** https://discord.com/developers/docs/resources/guild#delete-guild-role */
543
- deleteRole(roleId, reason) {
544
- this.client.rest.delete(rest_1.Endpoints.guildRole(this.id, roleId), {
545
- reason,
546
- });
547
- }
548
- /** https://discord.com/developers/docs/resources/guild#get-guild-prune-count */
549
- async getPruneCount(options) {
550
- return this.client.rest.get(rest_1.Endpoints.guildPrune(this.id), {
551
- query: {
552
- days: options.days,
553
- include_roles: options.includeRoles,
554
- },
555
- });
556
- }
557
- /** https://discord.com/developers/docs/resources/guild#begin-guild-prune */
558
- async beginGuildPrune(options, reason) {
559
- return this.client.rest.post(rest_1.Endpoints.guildPrune(this.id), {
560
- json: {
561
- days: options.days,
562
- compute_prune_count: options.computePruneCount,
563
- include_roles: options.includeRoles,
564
- reason: options.reason,
565
- },
566
- reason,
567
- });
568
- }
569
- /** https://discord.com/developers/docs/resources/guild#get-guild-voice-regions */
570
- async getVoiceRegions() {
571
- return this.client.rest
572
- .get(rest_1.Endpoints.guildVoiceRegions(this.id))
573
- .then((response) => response.map((data) => ({
574
- id: data.id,
575
- name: data.name,
576
- optimal: data.optimal,
577
- deprecated: data.deprecated,
578
- custom: data.custom,
579
- })));
580
- }
581
- /** https://discord.com/developers/docs/resources/guild#get-guild-invites */
582
- async getInvites() {
583
- return this.client.rest
584
- .get(rest_1.Endpoints.guildInvites(this.id))
585
- .then((response) => response.map((data) => new _1.Invite(data, this.client)));
586
- }
587
- /** https://discord.com/developers/docs/resources/guild#get-guild-integrations */
588
- async getIntegrations() {
589
- return this.client.rest
590
- .get(rest_1.Endpoints.guildIntegrations(this.id))
591
- .then((response) => response.map((data) => new _1.Integration(data, this.client)));
592
- }
593
- /** https://discord.com/developers/docs/resources/guild#delete-guild-integration */
594
- deleteIntegration(integrationId, reason) {
595
- this.client.rest.delete(rest_1.Endpoints.guildIntegration(this.id, integrationId), {
596
- reason,
597
- });
598
- }
599
- /** https://discord.com/developers/docs/resources/guild#get-guild-widget-settings */
600
- async getWidgetSettings() {
601
- return this.client.rest
602
- .get(rest_1.Endpoints.guildWidgetSettings(this.id))
603
- .then((response) => ({
604
- enabled: response.enabled,
605
- channelId: response.channel_id,
606
- }));
607
- }
608
- /** https://discord.com/developers/docs/resources/guild#modify-guild-widget */
609
- async editWidget(options, reason) {
610
- return this.client.rest
611
- .patch(rest_1.Endpoints.guildWidgetSettings(this.id), {
612
- json: {
613
- enabled: options.enabled,
614
- channel_id: options.channelId,
615
- },
616
- reason,
617
- })
618
- .then((response) => ({
619
- enabled: response.enabled,
620
- channelId: response.channel_id,
621
- }));
622
- }
623
- /** https://discord.com/developers/docs/resources/guild#get-guild-widget */
624
- async getWidget() {
625
- return this.client.rest
626
- .get(rest_1.Endpoints.guildWidgetJSON(this.id))
627
- .then((response) => ({
628
- id: response.id,
629
- name: response.name,
630
- instantInvite: response.instant_invite,
631
- channels: response.channels.map((data) => new _1.Channel(data, this.client)),
632
- members: response.members.map((data) => new _1.User(data, this.client)),
633
- presenceCount: response.presence_count,
634
- }));
635
- }
636
- /** https://discord.com/developers/docs/resources/guild#get-guild-vanity-url */
637
- getVanityURL() {
638
- return this.client.rest.get(rest_1.Endpoints.guildVanityUrl(this.id));
639
- }
640
- /** https://discord.com/developers/docs/resources/guild#get-guild-widget-image */
641
- async getWidgetImage(options) {
642
- return this.client.rest.get(rest_1.Endpoints.guildWidgetImage(this.id), {
643
- query: {
644
- style: options?.style,
645
- },
646
- });
647
- }
648
- /** https://discord.com/developers/docs/resources/guild#get-guild-welcome-screen */
649
- async getWelcomeScreen() {
650
- return this.client.rest
651
- .get(rest_1.Endpoints.guildWelcomeScreen(this.id))
652
- .then((response) => ({
653
- description: response.description,
654
- welcomeChannels: response.welcome_channels.map((data) => ({
655
- channelId: data.channel_id,
656
- description: data.description,
657
- emojiId: data.emoji_id,
658
- emojiName: data.emoji_name,
659
- })),
660
- }));
661
- }
662
- /** https://discord.com/developers/docs/resources/guild#modify-guild-welcome-screen */
663
- async editWelcomeScreen(options, reason) {
664
- return this.client.rest
665
- .patch(rest_1.Endpoints.guildWelcomeScreen(this.id), {
666
- json: {
667
- enabled: options.enabled,
668
- welcome_channels: options.welcomeChannels,
669
- description: options.description,
670
- },
671
- reason,
672
- })
673
- .then((response) => ({
674
- description: response.description,
675
- welcomeChannels: response.welcome_channels.map((data) => ({
676
- channelId: data.channel_id,
677
- description: data.description,
678
- emojiId: data.emoji_id,
679
- emojiName: data.emoji_name,
680
- })),
681
- }));
682
- }
683
- /** https://discord.com/developers/docs/resources/guild#get-guild-onboarding */
684
- async getOnboarding() {
685
- return this.client.rest
686
- .get(rest_1.Endpoints.guildOnboarding(this.id))
687
- .then((response) => ({
688
- guildId: response.guild_id,
689
- prompts: response.prompts.map((prompt) => ({
690
- id: prompt.id,
691
- type: prompt.type,
692
- options: prompt.options.map((option) => ({
693
- id: option.id,
694
- channelIds: option.channel_ids,
695
- roleIds: option.role_ids,
696
- emoji: option.emoji !== undefined
697
- ? new _1.Emoji(option.emoji, this.client)
698
- : undefined,
699
- emojiId: option.emoji_id,
700
- emojiName: option.emoji_name,
701
- emojiAnimated: option.emoji_animated,
702
- title: option.title,
703
- description: option.description,
704
- })),
705
- title: prompt.title,
706
- singleSelect: prompt.single_select,
707
- required: prompt.required,
708
- inOnboarding: prompt.in_onboarding,
709
- })),
710
- defaultChannelIds: response.default_channel_ids,
711
- enabled: response.enabled,
712
- mode: response.mode,
713
- }));
714
- }
715
- /** https://discord.com/developers/docs/resources/guild#modify-guild-onboarding */
716
- editOnboarding(options, reason) {
717
- this.client.rest.patch(rest_1.Endpoints.guildOnboarding(this.id), {
718
- json: {
719
- prompts: options.prompts.map((prompt) => ({
720
- id: prompt.id,
721
- type: prompt.type,
722
- options: prompt.options.map((option) => ({
723
- id: option.id,
724
- channel_ids: option.channelIds,
725
- role_ids: option.roleIds,
726
- emoji: option.emoji !== undefined
727
- ? {
728
- id: option.emoji.id,
729
- name: option.emoji.name,
730
- roles: option.emoji.roles,
731
- user: option.emoji.user,
732
- require_colons: option.emoji.requireColons,
733
- managed: option.emoji.managed,
734
- animated: option.emoji.animated,
735
- available: option.emoji.available,
736
- }
737
- : undefined,
738
- emoji_id: option.emojiId,
739
- emoji_name: option.emojiName,
740
- emoji_animated: option.emojiAnimated,
741
- title: option.title,
742
- description: option.description,
743
- })),
744
- title: prompt.title,
745
- single_select: prompt.singleSelect,
746
- required: prompt.required,
747
- in_onboarding: prompt.inOnboarding,
748
- })),
749
- },
750
- reason,
751
- });
752
- }
753
- /** https://discord.com/developers/docs/resources/guild#modify-current-user-voice-state */
754
- editCurrentUserVoiceState(options) {
755
- this.client.rest.patch(rest_1.Endpoints.guildVoiceState(this.id), {
756
- json: {
757
- channel_id: options.channelId,
758
- suppress: options.suppress,
759
- requestToSpeakTimestamp: options.requestToSpeakTimestamp,
760
- },
761
- });
762
- }
763
- /** https://discord.com/developers/docs/resources/guild#modify-user-voice-state */
764
- editUserVoiceState(userId, options) {
765
- this.client.rest.patch(rest_1.Endpoints.guildVoiceState(this.id, userId), {
766
- json: {
767
- channel_id: options.channelId,
768
- suppress: options.suppress,
769
- requestToSpeakTimestamp: options.requestToSpeakTimestamp,
770
- },
771
- });
772
- }
773
- /** https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild */
774
- async getScheduledEvents(options) {
775
- return this.client.rest
776
- .get(rest_1.Endpoints.guildScheduledEvents(this.id), {
777
- query: {
778
- with_user_count: options?.withUserCount,
779
- },
780
- })
781
- .then((response) => response.map((data) => new _1.GuildScheduledEvent(data, this.client)));
782
- }
783
- /** https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event */
784
- async createScheduledEvent(options, reason) {
785
- return new _1.GuildScheduledEvent(await this.client.rest.post(rest_1.Endpoints.guildScheduledEvents(this.id), {
786
- json: {
787
- channel_id: options.channelId,
788
- entity_metadata: options.entityMetadata,
789
- name: options.name,
790
- privacy_level: options.privacyLevel,
791
- scheduled_start_time: options.scheduledEndTime,
792
- scheduled_end_time: options.scheduledEndTime,
793
- description: options.description,
794
- entity_type: options.entityType,
795
- image: options.image,
796
- },
797
- reason,
798
- }), this.client);
799
- }
800
- /** https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event */
801
- async editScheduledEvent(scheduledEventId, options, reason) {
802
- return new _1.GuildScheduledEvent(await this.client.rest.patch(rest_1.Endpoints.guildScheduledEvent(this.id, scheduledEventId), {
803
- json: {
804
- channel_id: options.channelId,
805
- entity_metadata: options.entityMetadata,
806
- name: options.name,
807
- privacy_level: options.privacyLevel,
808
- scheduled_start_time: options.scheduledStartTime,
809
- scheduled_end_time: options.scheduledEndTime,
810
- description: options.description,
811
- entityType: options.entityType,
812
- status: options.status,
813
- image: options.image,
814
- },
815
- reason,
816
- }), this.client);
817
- }
818
- /** https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event */
819
- deleteScheduledEvent(scheduledEventId) {
820
- this.client.rest.delete(rest_1.Endpoints.guildScheduledEvent(this.id, scheduledEventId));
821
- }
822
- /** https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users */
823
- async getScheduledEventUsers(scheduledEventId, options) {
824
- return this.client.rest
825
- .get(rest_1.Endpoints.guildScheduledEvent(this.id, scheduledEventId), {
826
- query: {
827
- limit: options?.limit,
828
- with_member: options?.withMember,
829
- before: options?.before,
830
- after: options?.after,
831
- },
832
- })
833
- .then((response) => response.map((data) => ({
834
- guildScheduledEventId: data.guild_scheduled_event_id,
835
- user: new _1.User(data.user, this.client),
836
- member: data.member !== undefined
837
- ? new _1.GuildMember(data.member, this.client)
838
- : undefined,
839
- })));
840
- }
841
- /** https://discord.com/developers/docs/resources/guild-template#get-guild-template */
842
- async getTemplate(code) {
843
- return new _1.GuildTemplate(await this.client.rest.get(rest_1.Endpoints.guildTemplate(this.id, code)), this.client);
844
- }
845
- /** https://discord.com/developers/docs/resources/guild-template#get-guild-templates */
846
- async getTemplates() {
847
- return this.client.rest
848
- .get(rest_1.Endpoints.guildTemplates(this.id))
849
- .then((response) => response.map((data) => new _1.GuildTemplate(data, this.client)));
850
- }
851
- /** https://discord.com/developers/docs/resources/guild-template#create-guild-template */
852
- async createTemplate(options) {
853
- return new _1.GuildTemplate(await this.client.rest.post(rest_1.Endpoints.guildTemplates(this.id), {
854
- json: {
855
- name: options.name,
856
- description: options.description,
857
- },
858
- }), this.client);
859
- }
860
- /** https://discord.com/developers/docs/resources/guild-template#sync-guild-template */
861
- async syncTemplate(code) {
862
- return new _1.GuildTemplate(await this.client.rest.put(rest_1.Endpoints.guildTemplate(this.id, code)), this.client);
863
- }
864
- /** https://discord.com/developers/docs/resources/guild-template#modify-guild-template */
865
- async editTemplate(code, options) {
866
- return new _1.GuildTemplate(await this.client.rest.patch(rest_1.Endpoints.guildTemplate(this.id, code), {
867
- json: {
868
- name: options.name,
869
- description: options.description,
870
- },
871
- }), this.client);
872
- }
873
- /** https://discord.com/developers/docs/resources/guild-template#delete-guild-template */
874
- async deleteTemplate(code) {
875
- return this.client.rest
876
- .delete(rest_1.Endpoints.guildTemplate(this.id, code))
877
- .then((response) => new _1.GuildTemplate(response, this.client).toJSON());
878
- }
879
- /** https://discord.com/developers/docs/resources/sticker#list-guild-stickers */
880
- async getStickers() {
881
- return this.client.rest
882
- .get(rest_1.Endpoints.guildStickers(this.id))
883
- .then((response) => response.map((data) => new _1.Sticker(data, this.client)));
884
- }
885
- /** https://discord.com/developers/docs/resources/sticker#get-guild-sticker */
886
- async getSticker(stickerId) {
887
- return this.client.rest
888
- .get(rest_1.Endpoints.guildSticker(this.id, stickerId))
889
- .then((response) => new _1.Sticker(response, this.client));
890
- }
891
- /** https://discord.com/developers/docs/resources/sticker#create-guild-sticker */
892
- async createSticker(options, reason) {
893
- const formData = new undici_1.FormData();
894
- formData.set("name", options.name);
895
- formData.set("description", options.description);
896
- formData.set("tags", options.tags);
897
- formData.set("file", new undici_1.File([options.file.contents], options.file.name));
898
- return this.client.rest
899
- .post(rest_1.Endpoints.guildStickers(this.id), {
900
- form: formData,
901
- reason,
902
- })
903
- .then((response) => new _1.Sticker(response, this.client));
904
- }
905
- /** https://discord.com/developers/docs/resources/sticker#modify-guild-sticker */
906
- async editSticker(stickerId, options, reason) {
907
- return this.client.rest
908
- .patch(rest_1.Endpoints.guildSticker(this.id, stickerId), {
909
- json: {
910
- name: options.name,
911
- description: options.description,
912
- tags: options.tags,
913
- },
914
- reason,
915
- })
916
- .then((response) => new _1.Sticker(response, this.client));
917
- }
918
- /** https://discord.com/developers/docs/resources/sticker#delete-guild-sticker */
919
- deleteSticker(stickerId, reason) {
920
- this.client.rest.delete(rest_1.Endpoints.guildSticker(this.id, stickerId), {
921
- reason,
922
- });
923
- }
924
- /** https://discord.com/developers/docs/resources/webhook#get-guild-webhooks */
925
- async getWebhooks() {
926
- return this.client.rest
927
- .get(rest_1.Endpoints.guildWebhooks(this.id))
928
- .then((response) => response.map((data) => new _1.Webhook(data, this.client)));
929
- }
930
14
  toRaw() {
931
15
  return this.raw;
932
16
  }
933
17
  toJSON() {
934
18
  return {
935
- id: this.id,
19
+ ...super.toJSON(),
936
20
  unavailable: this.unavailable,
937
21
  };
938
22
  }