discord.js 15.0.0-dev.1738066825-6df42db33 → 15.0.0-dev.1738152305-5f463eb9e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,7 +9,8 @@
9
9
  <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/v/discord.js.svg?maxAge=3600" alt="npm version" /></a>
10
10
  <a href="https://www.npmjs.com/package/discord.js"><img src="https://img.shields.io/npm/dt/discord.js.svg?maxAge=3600" alt="npm downloads" /></a>
11
11
  <a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Tests status" /></a>
12
- <a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
12
+ <a href="https://github.com/discordjs/discord.js/commits/main/packages/discord.js"><img alt="Last commit." src="https://img.shields.io/github/last-commit/discordjs/discord.js?logo=github&logoColor=ffffff&path=packages%2Fdiscord.js"></a>
13
+ <a href="https://codecov.io/gh/discordjs/discord.js"><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2" alt="Code coverage" /></a>
13
14
  </p>
14
15
  <p>
15
16
  <a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "discord.js",
4
- "version": "15.0.0-dev.1738066825-6df42db33",
4
+ "version": "15.0.0-dev.1738152305-5f463eb9e",
5
5
  "description": "A powerful library for interacting with the Discord API",
6
6
  "main": "./src/index.js",
7
7
  "types": "./typings/index.d.ts",
@@ -61,10 +61,10 @@
61
61
  "tslib": "^2.8.1",
62
62
  "undici": "6.21.0",
63
63
  "@discordjs/collection": "^2.1.1",
64
- "@discordjs/formatters": "^0.5.0",
64
+ "@discordjs/rest": "^2.4.0",
65
65
  "@discordjs/util": "^1.1.1",
66
- "@discordjs/ws": "^2.0.0",
67
- "@discordjs/rest": "^2.4.0"
66
+ "@discordjs/formatters": "^0.5.0",
67
+ "@discordjs/ws": "^2.0.0"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@favware/cliff-jumper": "^4.1.0",
@@ -18,6 +18,7 @@ const { resolveImage } = require('../util/DataResolver.js');
18
18
  const { Events } = require('../util/Events.js');
19
19
  const { PermissionsBitField } = require('../util/PermissionsBitField.js');
20
20
  const { SystemChannelFlagsBitField } = require('../util/SystemChannelFlagsBitField.js');
21
+ const { _transformAPIIncidentsData } = require('../util/Transformers.js');
21
22
  const { resolveColor } = require('../util/Util.js');
22
23
 
23
24
  let cacheWarningEmitted = false;
@@ -281,6 +282,39 @@ class GuildManager extends CachedManager {
281
282
  return data.reduce((coll, guild) => coll.set(guild.id, new OAuth2Guild(this.client, guild)), new Collection());
282
283
  }
283
284
 
285
+ /**
286
+ * Options used to set incident actions. Supplying `null` to any option will disable the action.
287
+ * @typedef {Object} IncidentActionsEditOptions
288
+ * @property {?DateResolvable} [invitesDisabledUntil] When invites should be enabled again
289
+ * @property {?DateResolvable} [dmsDisabledUntil] When direct messages should be enabled again
290
+ */
291
+
292
+ /**
293
+ * Sets the incident actions for a guild.
294
+ * @param {GuildResolvable} guild The guild
295
+ * @param {IncidentActionsEditOptions} incidentActions The incident actions to set
296
+ * @returns {Promise<IncidentActions>}
297
+ */
298
+ async setIncidentActions(guild, { invitesDisabledUntil, dmsDisabledUntil }) {
299
+ const guildId = this.resolveId(guild);
300
+
301
+ const data = await this.client.rest.put(Routes.guildIncidentActions(guildId), {
302
+ body: {
303
+ invites_disabled_until: invitesDisabledUntil && new Date(invitesDisabledUntil).toISOString(),
304
+ dms_disabled_until: dmsDisabledUntil && new Date(dmsDisabledUntil).toISOString(),
305
+ },
306
+ });
307
+
308
+ const parsedData = _transformAPIIncidentsData(data);
309
+ const resolvedGuild = this.resolve(guild);
310
+
311
+ if (resolvedGuild) {
312
+ resolvedGuild.incidentsData = parsedData;
313
+ }
314
+
315
+ return parsedData;
316
+ }
317
+
284
318
  /**
285
319
  * Returns a URL for the PNG widget of a guild.
286
320
  * @param {GuildResolvable} guild The guild of the widget image
@@ -102,7 +102,7 @@ class ThreadManager extends CachedManager {
102
102
  * Data that can be resolved to a Date object. This can be:
103
103
  * * A Date object
104
104
  * * A number representing a timestamp
105
- * * An [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) string
105
+ * * An {@link https://en.wikipedia.org/wiki/ISO_8601 ISO 8601} string
106
106
  * @typedef {Date|number|string} DateResolvable
107
107
  */
108
108
 
@@ -202,7 +202,8 @@ class ShardClientUtil {
202
202
  * Emitted when the client encounters an error.
203
203
  * <warn>Errors thrown within this event do not have a catch handler, it is
204
204
  * recommended to not use async functions as `error` event handlers. See the
205
- * [Node.js docs](https://nodejs.org/api/events.html#capture-rejections-of-promises) for details.</warn>
205
+ * {@link https://nodejs.org/api/events.html#capture-rejections-of-promises Node.js documentation}
206
+ * for details.)</warn>
206
207
  * @event Client#error
207
208
  * @param {Error} error The error encountered
208
209
  */
@@ -28,6 +28,7 @@ const { StageInstanceManager } = require('../managers/StageInstanceManager.js');
28
28
  const { VoiceStateManager } = require('../managers/VoiceStateManager.js');
29
29
  const { resolveImage } = require('../util/DataResolver.js');
30
30
  const { SystemChannelFlagsBitField } = require('../util/SystemChannelFlagsBitField.js');
31
+ const { _transformAPIIncidentsData } = require('../util/Transformers.js');
31
32
  const { discordSort, getSortableGroupTypes, resolvePartialEmoji } = require('../util/Util.js');
32
33
 
33
34
  /**
@@ -460,6 +461,27 @@ class Guild extends AnonymousGuild {
460
461
  stickers: data.stickers,
461
462
  });
462
463
  }
464
+
465
+ if ('incidents_data' in data) {
466
+ /**
467
+ * Incident actions of a guild.
468
+ * @typedef {Object} IncidentActions
469
+ * @property {?Date} invitesDisabledUntil When invites would be enabled again
470
+ * @property {?Date} dmsDisabledUntil When direct messages would be enabled again
471
+ * @property {?Date} dmSpamDetectedAt When direct message spam was detected
472
+ * @property {?Date} raidDetectedAt When a raid was detected
473
+ */
474
+
475
+ /**
476
+ * The incidents data of this guild.
477
+ * <info>You will need to fetch the guild using {@link BaseGuild#fetch} if you want to receive
478
+ * this property.</info>
479
+ * @type {?IncidentActions}
480
+ */
481
+ this.incidentsData = data.incidents_data && _transformAPIIncidentsData(data.incidents_data);
482
+ } else {
483
+ this.incidentsData ??= null;
484
+ }
463
485
  }
464
486
 
465
487
  /**
@@ -1355,6 +1377,15 @@ class Guild extends AnonymousGuild {
1355
1377
  return this.edit({ features });
1356
1378
  }
1357
1379
 
1380
+ /**
1381
+ * Sets the incident actions for a guild.
1382
+ * @param {IncidentActionsEditOptions} incidentActions The incident actions to set
1383
+ * @returns {Promise<IncidentActions>}
1384
+ */
1385
+ async setIncidentActions(incidentActions) {
1386
+ return this.client.guilds.setIncidentActions(this.id, incidentActions);
1387
+ }
1388
+
1358
1389
  /**
1359
1390
  * Whether this guild equals another guild. It compares all properties, so for most operations
1360
1391
  * it is advisable to just compare `guild.id === guild2.id` as it is much faster and is often
@@ -75,7 +75,7 @@ class TextBasedChannel {
75
75
  * @property {?string} [content=''] The content for the message. This can only be `null` when editing a message.
76
76
  * @property {Array<(EmbedBuilder|Embed|APIEmbed)>} [embeds] The embeds for the message
77
77
  * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
78
- * (see [here](https://discord.com/developers/docs/resources/message#allowed-mentions-object) for more details)
78
+ * (see {@link https://discord.com/developers/docs/resources/message#allowed-mentions-object here} for more details)
79
79
  * @property {Array<(AttachmentBuilder|Attachment|AttachmentPayload|BufferResolvable)>} [files]
80
80
  * The files to send with the message.
81
81
  * @property {Array<(ActionRowBuilder|ActionRow|APIActionRowComponent)>} [components]
@@ -105,6 +105,11 @@
105
105
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIGuildScheduledEventRecurrenceRule}
106
106
  */
107
107
 
108
+ /**
109
+ * @external APIIncidentsData
110
+ * @see {@link https://discord-api-types.dev/api/discord-api-types-v10/interface/APIIncidentsData}
111
+ */
112
+
108
113
  /**
109
114
  * @external APIInteraction
110
115
  * @see {@link https://discord-api-types.dev/api/discord-api-types-v10#APIInteraction}
@@ -72,7 +72,23 @@ function _transformGuildScheduledEventRecurrenceRule(recurrenceRule) {
72
72
  };
73
73
  }
74
74
 
75
+ /**
76
+ * Transforms API incidents data to a camel-cased variant.
77
+ * @param {APIIncidentsData} data The incidents data to transform
78
+ * @returns {IncidentActions}
79
+ * @ignore
80
+ */
81
+ function _transformAPIIncidentsData(data) {
82
+ return {
83
+ invitesDisabledUntil: data.invites_disabled_until ? new Date(data.invites_disabled_until) : null,
84
+ dmsDisabledUntil: data.dms_disabled_until ? new Date(data.dms_disabled_until) : null,
85
+ dmSpamDetectedAt: data.dm_spam_detected_at ? new Date(data.dm_spam_detected_at) : null,
86
+ raidDetectedAt: data.raid_detected_at ? new Date(data.raid_detected_at) : null,
87
+ };
88
+ }
89
+
75
90
  exports.toSnakeCase = toSnakeCase;
76
91
  exports._transformAPIAutoModerationAction = _transformAPIAutoModerationAction;
77
92
  exports._transformAPIMessageInteractionMetadata = _transformAPIMessageInteractionMetadata;
78
93
  exports._transformGuildScheduledEventRecurrenceRule = _transformGuildScheduledEventRecurrenceRule;
94
+ exports._transformAPIIncidentsData = _transformAPIIncidentsData;
@@ -1407,6 +1407,7 @@ export class Guild extends AnonymousGuild {
1407
1407
  public shardId: number;
1408
1408
  public stageInstances: StageInstanceManager;
1409
1409
  public stickers: GuildStickerManager;
1410
+ public incidentsData: IncidentActions | null;
1410
1411
  public get systemChannel(): TextChannel | null;
1411
1412
  public systemChannelFlags: Readonly<SystemChannelFlagsBitField>;
1412
1413
  public systemChannelId: Snowflake | null;
@@ -1446,6 +1447,7 @@ export class Guild extends AnonymousGuild {
1446
1447
  public widgetImageURL(style?: GuildWidgetStyle): string;
1447
1448
  public leave(): Promise<Guild>;
1448
1449
  public disableInvites(disabled?: boolean): Promise<Guild>;
1450
+ public setIncidentActions(incidentActions: IncidentActionsEditOptions): Promise<IncidentActions>;
1449
1451
  public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
1450
1452
  public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
1451
1453
  public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
@@ -4172,6 +4174,10 @@ export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvabl
4172
4174
  public create(options: GuildCreateOptions): Promise<Guild>;
4173
4175
  public fetch(options: Snowflake | FetchGuildOptions): Promise<Guild>;
4174
4176
  public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
4177
+ public setIncidentActions(
4178
+ guild: GuildResolvable,
4179
+ incidentActions: IncidentActionsEditOptions,
4180
+ ): Promise<IncidentActions>;
4175
4181
  public widgetImageURL(guild: GuildResolvable, style?: GuildWidgetStyle): string;
4176
4182
  }
4177
4183
 
@@ -6064,6 +6070,18 @@ export interface GuildOnboardingPromptOptionData {
6064
6070
 
6065
6071
  export type HexColorString = `#${string}`;
6066
6072
 
6073
+ export interface IncidentActions {
6074
+ invitesDisabledUntil: Date | null;
6075
+ dmsDisabledUntil: Date | null;
6076
+ dmSpamDetectedAt: Date | null;
6077
+ raidDetectedAt: Date | null;
6078
+ }
6079
+
6080
+ export interface IncidentActionsEditOptions {
6081
+ invitesDisabledUntil?: DateResolvable | null | undefined;
6082
+ dmsDisabledUntil?: DateResolvable | null | undefined;
6083
+ }
6084
+
6067
6085
  export interface IntegrationAccount {
6068
6086
  id: string | Snowflake;
6069
6087
  name: string;
@@ -1407,6 +1407,7 @@ export class Guild extends AnonymousGuild {
1407
1407
  public shardId: number;
1408
1408
  public stageInstances: StageInstanceManager;
1409
1409
  public stickers: GuildStickerManager;
1410
+ public incidentsData: IncidentActions | null;
1410
1411
  public get systemChannel(): TextChannel | null;
1411
1412
  public systemChannelFlags: Readonly<SystemChannelFlagsBitField>;
1412
1413
  public systemChannelId: Snowflake | null;
@@ -1446,6 +1447,7 @@ export class Guild extends AnonymousGuild {
1446
1447
  public widgetImageURL(style?: GuildWidgetStyle): string;
1447
1448
  public leave(): Promise<Guild>;
1448
1449
  public disableInvites(disabled?: boolean): Promise<Guild>;
1450
+ public setIncidentActions(incidentActions: IncidentActionsEditOptions): Promise<IncidentActions>;
1449
1451
  public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
1450
1452
  public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
1451
1453
  public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
@@ -4172,6 +4174,10 @@ export class GuildManager extends CachedManager<Snowflake, Guild, GuildResolvabl
4172
4174
  public create(options: GuildCreateOptions): Promise<Guild>;
4173
4175
  public fetch(options: Snowflake | FetchGuildOptions): Promise<Guild>;
4174
4176
  public fetch(options?: FetchGuildsOptions): Promise<Collection<Snowflake, OAuth2Guild>>;
4177
+ public setIncidentActions(
4178
+ guild: GuildResolvable,
4179
+ incidentActions: IncidentActionsEditOptions,
4180
+ ): Promise<IncidentActions>;
4175
4181
  public widgetImageURL(guild: GuildResolvable, style?: GuildWidgetStyle): string;
4176
4182
  }
4177
4183
 
@@ -6064,6 +6070,18 @@ export interface GuildOnboardingPromptOptionData {
6064
6070
 
6065
6071
  export type HexColorString = `#${string}`;
6066
6072
 
6073
+ export interface IncidentActions {
6074
+ invitesDisabledUntil: Date | null;
6075
+ dmsDisabledUntil: Date | null;
6076
+ dmSpamDetectedAt: Date | null;
6077
+ raidDetectedAt: Date | null;
6078
+ }
6079
+
6080
+ export interface IncidentActionsEditOptions {
6081
+ invitesDisabledUntil?: DateResolvable | null | undefined;
6082
+ dmsDisabledUntil?: DateResolvable | null | undefined;
6083
+ }
6084
+
6067
6085
  export interface IntegrationAccount {
6068
6086
  id: string | Snowflake;
6069
6087
  name: string;