discord.js 15.0.0-dev.1737936752-3db8ce70a → 15.0.0-dev.1738109528-fa0d4b507
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/package.json +6 -6
- package/src/managers/GuildManager.js +34 -0
- package/src/structures/Guild.js +31 -0
- package/src/util/APITypes.js +5 -0
- package/src/util/Transformers.js +16 -0
- package/typings/index.d.mts +18 -0
- package/typings/index.d.ts +18 -0
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.
|
|
4
|
+
"version": "15.0.0-dev.1738109528-fa0d4b507",
|
|
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",
|
|
@@ -55,16 +55,16 @@
|
|
|
55
55
|
"@discordjs/builders": "^1.9.0",
|
|
56
56
|
"@sapphire/snowflake": "3.5.5",
|
|
57
57
|
"@vladfrangu/async_event_emitter": "^2.4.6",
|
|
58
|
-
"discord-api-types": "^0.37.
|
|
58
|
+
"discord-api-types": "^0.37.118",
|
|
59
59
|
"fast-deep-equal": "3.1.3",
|
|
60
60
|
"lodash.snakecase": "4.1.1",
|
|
61
61
|
"tslib": "^2.8.1",
|
|
62
62
|
"undici": "6.21.0",
|
|
63
|
+
"@discordjs/formatters": "^0.5.0",
|
|
63
64
|
"@discordjs/collection": "^2.1.1",
|
|
64
65
|
"@discordjs/rest": "^2.4.0",
|
|
65
66
|
"@discordjs/util": "^1.1.1",
|
|
66
|
-
"@discordjs/ws": "^2.0.0"
|
|
67
|
-
"@discordjs/formatters": "^0.5.0"
|
|
67
|
+
"@discordjs/ws": "^2.0.0"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@favware/cliff-jumper": "^4.1.0",
|
|
@@ -82,8 +82,8 @@
|
|
|
82
82
|
"turbo": "^2.3.3",
|
|
83
83
|
"typescript": "~5.5.4",
|
|
84
84
|
"@discordjs/docgen": "^0.12.1",
|
|
85
|
-
"@discordjs/
|
|
86
|
-
"@discordjs/
|
|
85
|
+
"@discordjs/scripts": "^0.1.0",
|
|
86
|
+
"@discordjs/api-extractor": "^7.38.1"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|
|
89
89
|
"node": ">=22.12.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
|
package/src/structures/Guild.js
CHANGED
|
@@ -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
|
package/src/util/APITypes.js
CHANGED
|
@@ -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}
|
package/src/util/Transformers.js
CHANGED
|
@@ -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;
|
package/typings/index.d.mts
CHANGED
|
@@ -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;
|
package/typings/index.d.ts
CHANGED
|
@@ -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;
|