@discordjs/structures 0.2.0-dev.1769083302-838cd2da3 → 0.2.0-dev.1769385723-323d8e757

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/dist/index.js CHANGED
@@ -28,6 +28,10 @@ __export(index_exports, {
28
28
  AppliedTagsMixin: () => AppliedTagsMixin,
29
29
  Attachment: () => Attachment,
30
30
  AttachmentFlagsBitField: () => AttachmentFlagsBitField,
31
+ AutoModerationAction: () => AutoModerationAction,
32
+ AutoModerationActionMetadata: () => AutoModerationActionMetadata,
33
+ AutoModerationRule: () => AutoModerationRule,
34
+ AutoModerationRuleTriggerMetadata: () => AutoModerationRuleTriggerMetadata,
31
35
  AvatarDecorationData: () => AvatarDecorationData,
32
36
  BitField: () => BitField,
33
37
  ButtonComponent: () => ButtonComponent,
@@ -127,6 +131,338 @@ __export(index_exports, {
127
131
  });
128
132
  module.exports = __toCommonJS(index_exports);
129
133
 
134
+ // src/utils/symbols.ts
135
+ var kData = /* @__PURE__ */ Symbol.for("djs.structures.data");
136
+ var kClone = /* @__PURE__ */ Symbol.for("djs.structures.clone");
137
+ var kPatch = /* @__PURE__ */ Symbol.for("djs.structures.patch");
138
+ var kExpiresTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.expiresTimestamp");
139
+ var kEndedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.endedTimestamp");
140
+ var kCreatedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.createdTimestamp");
141
+ var kEditedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.editedTimestamp");
142
+ var kArchiveTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.archiveTimestamp");
143
+ var kStartsTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.startsTimestamp");
144
+ var kEndsTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.endsTimestamp");
145
+ var kAllow = /* @__PURE__ */ Symbol.for("djs.structures.allow");
146
+ var kDeny = /* @__PURE__ */ Symbol.for("djs.structures.deny");
147
+ var kBurstColors = /* @__PURE__ */ Symbol.for("djs.structures.burstColors");
148
+ var kLastPinTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.lastPinTimestamp");
149
+ var kMixinConstruct = /* @__PURE__ */ Symbol.for("djs.structures.mixin.construct");
150
+ var kMixinToJSON = /* @__PURE__ */ Symbol.for("djs.structures.mixin.toJSON");
151
+
152
+ // src/Structure.ts
153
+ var DataTemplatePropertyName = "DataTemplate";
154
+ var OptimizeDataPropertyName = "optimizeData";
155
+ var Structure = class {
156
+ static {
157
+ __name(this, "Structure");
158
+ }
159
+ /**
160
+ * The template used for removing data from the raw data stored for each Structure.
161
+ *
162
+ * @remarks This template should be overridden in all subclasses to provide more accurate type information.
163
+ * The template in the base {@link Structure} class will have no effect on most subclasses for this reason.
164
+ */
165
+ static DataTemplate = {};
166
+ /**
167
+ * @returns A cloned version of the data template, ready to create a new data object.
168
+ */
169
+ getDataTemplate() {
170
+ return Object.create(this.constructor.DataTemplate);
171
+ }
172
+ /**
173
+ * The raw data from the API for this structure
174
+ *
175
+ * @internal
176
+ */
177
+ [kData];
178
+ /**
179
+ * Creates a new structure to represent API data
180
+ *
181
+ * @param data - the data from the API that this structure will represent
182
+ * @remarks To be made public in subclasses
183
+ * @internal
184
+ */
185
+ constructor(data, ..._rest) {
186
+ this[kData] = Object.assign(this.getDataTemplate(), data);
187
+ this[kMixinConstruct]?.(data);
188
+ }
189
+ /**
190
+ * Patches the raw data of this object in place
191
+ *
192
+ * @param data - the updated data from the API to patch with
193
+ * @remarks To be made public in subclasses
194
+ * @returns this
195
+ * @internal
196
+ */
197
+ [kPatch](data) {
198
+ this[kData] = Object.assign(this.getDataTemplate(), this[kData], data);
199
+ this.optimizeData(data);
200
+ return this;
201
+ }
202
+ /**
203
+ * Creates a clone of this structure
204
+ *
205
+ * @returns a clone of this
206
+ * @internal
207
+ */
208
+ [kClone](patchPayload) {
209
+ const clone = this.toJSON();
210
+ return new this.constructor(
211
+ // Ensure the ts-expect-error only applies to the constructor call
212
+ patchPayload ? Object.assign(clone, patchPayload) : clone
213
+ );
214
+ }
215
+ /**
216
+ * Function called to ensure stored raw data is in optimized formats, used in tandem with a data template
217
+ *
218
+ * @example created_timestamp is an ISO string, this can be stored in optimized form as a number
219
+ * @param _data - the raw data received from the API to optimize
220
+ * @remarks Implementation to be done in subclasses and mixins where needed.
221
+ * For typescript users, mixins must use the closest ancestors access modifier.
222
+ * @remarks Automatically called in Structure[kPatch] but must be called manually in the constructor
223
+ * of any class implementing this method.
224
+ * @remarks Additionally, when implementing, ensure to call `super._optimizeData` if any class in the super chain aside
225
+ * from Structure contains an implementation.
226
+ * Note: mixins do not need to call super ever as the process of mixing walks the prototype chain.
227
+ * @virtual
228
+ * @internal
229
+ */
230
+ optimizeData(_data) {
231
+ }
232
+ /**
233
+ * Transforms this object to its JSON format with raw API data (or close to it),
234
+ * automatically called by `JSON.stringify()` when this structure is stringified
235
+ *
236
+ * @remarks
237
+ * The type of this data is determined by omissions at runtime and is only guaranteed for default omissions
238
+ * @privateRemarks
239
+ * When omitting properties at the library level, this must be overridden to re-add those properties
240
+ */
241
+ toJSON() {
242
+ const data = (
243
+ // Spread is way faster than structuredClone, but is shallow. So use it only if there is no nested objects
244
+ Object.values(this[kData]).some((value) => typeof value === "object" && value !== null) ? structuredClone(this[kData]) : { ...this[kData] }
245
+ );
246
+ this[kMixinToJSON]?.(data);
247
+ return data;
248
+ }
249
+ };
250
+
251
+ // src/automoderation/actions/AutoModerationAction.ts
252
+ var AutoModerationAction = class extends Structure {
253
+ static {
254
+ __name(this, "AutoModerationAction");
255
+ }
256
+ /**
257
+ * The template used for removing data from the raw data stored for each auto moderation action
258
+ */
259
+ static DataTemplate = {};
260
+ /**
261
+ * @param data - The raw data received from the API for the auto moderation action
262
+ */
263
+ constructor(data) {
264
+ super(data);
265
+ }
266
+ /**
267
+ * The {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-action-object-action-types | action type}
268
+ */
269
+ get type() {
270
+ return this[kData].type;
271
+ }
272
+ };
273
+
274
+ // src/automoderation/actions/AutoModerationActionMetadata.ts
275
+ var AutoModerationActionMetadata = class extends Structure {
276
+ static {
277
+ __name(this, "AutoModerationActionMetadata");
278
+ }
279
+ /**
280
+ * The template used for removing data from the raw data stored for each auto moderation action metadata
281
+ */
282
+ static DataTemplate = {};
283
+ /**
284
+ * @param data - The raw data received from the API for the auto moderation action metadata
285
+ */
286
+ constructor(data) {
287
+ super(data);
288
+ }
289
+ /**
290
+ * Channel to which user content should be logged. This must be an existing channel
291
+ *
292
+ * Associated action types: {@link AutoModerationActionType.SendAlertMessage}
293
+ */
294
+ get channelId() {
295
+ return this[kData].channel_id;
296
+ }
297
+ /**
298
+ * Timeout duration in seconds. Maximum of 2419200 seconds (4 weeks).
299
+ *
300
+ * A `TIMEOUT` action can only be set up for {@link AutoModerationRuleTriggerType.Keyword} and {@link AutoModerationRuleTriggerType.MentionSpam}.
301
+ *
302
+ * The `MODERATE_MEMBERS` permission is required to use {@link AutoModerationActionType.Timeout} actions.
303
+ *
304
+ * Associated action types: {@link AutoModerationActionType.Timeout}
305
+ */
306
+ get durationSeconds() {
307
+ return this[kData].duration_seconds;
308
+ }
309
+ /**
310
+ * Additional explanation that will be shown to members whenever their message is blocked. Maximum of 150 characters
311
+ *
312
+ * Associated action types: {@link AutoModerationActionType.BlockMessage}
313
+ */
314
+ get customMessage() {
315
+ return this[kData].custom_message;
316
+ }
317
+ };
318
+
319
+ // src/automoderation/AutoModerationRule.ts
320
+ var AutoModerationRule = class extends Structure {
321
+ static {
322
+ __name(this, "AutoModerationRule");
323
+ }
324
+ /**
325
+ * The template used for removing data from the raw data stored for each auto moderation rule
326
+ */
327
+ static DataTemplate = {};
328
+ /**
329
+ * @param data - The raw data received from the API for the auto moderation rule
330
+ */
331
+ constructor(data) {
332
+ super(data);
333
+ }
334
+ /**
335
+ * The id of this rule
336
+ */
337
+ get id() {
338
+ return this[kData].id;
339
+ }
340
+ /**
341
+ * The id of the guild which this rule belongs to
342
+ */
343
+ get guildId() {
344
+ return this[kData].guild_id;
345
+ }
346
+ /**
347
+ * The rule name
348
+ */
349
+ get name() {
350
+ return this[kData].name;
351
+ }
352
+ /**
353
+ * The user who first created this rule
354
+ */
355
+ get creatorId() {
356
+ return this[kData].creator_id;
357
+ }
358
+ /**
359
+ * The rule {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-event-types | event type}
360
+ */
361
+ get eventType() {
362
+ return this[kData].event_type;
363
+ }
364
+ /**
365
+ * The rule {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types | trigger type}
366
+ */
367
+ get triggerType() {
368
+ return this[kData].trigger_type;
369
+ }
370
+ /**
371
+ * Whether the rule is enabled
372
+ */
373
+ get enabled() {
374
+ return this[kData].enabled;
375
+ }
376
+ };
377
+
378
+ // src/automoderation/AutoModerationRuleTriggerMetadata.ts
379
+ var AutoModerationRuleTriggerMetadata = class extends Structure {
380
+ static {
381
+ __name(this, "AutoModerationRuleTriggerMetadata");
382
+ }
383
+ /**
384
+ * The template used for removing data from the raw data stored for each auto moderation rule trigger metadata
385
+ */
386
+ static DataTemplate = {};
387
+ /**
388
+ * @param data - The raw data received from the API for the auto moderation rule trigger metadata
389
+ */
390
+ constructor(data) {
391
+ super(data);
392
+ }
393
+ /**
394
+ * Substrings which will be searched for in content (Maximum of 1000)
395
+ *
396
+ * A keyword can be a phrase which contains multiple words.
397
+ *
398
+ * Wildcard symbols can be used to customize how each keyword will be matched. Each keyword must be 60 characters or less.
399
+ *
400
+ * @see {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies | Keyword matching strategies}
401
+ *
402
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.MemberProfile}
403
+ */
404
+ get keywordFilter() {
405
+ return this[kData].keyword_filter;
406
+ }
407
+ /**
408
+ * Regular expression patterns which will be matched against content (Maximum of 10)
409
+ *
410
+ * Only Rust flavored regex is currently supported, which can be tested in online editors such as {@link https://rustexp.lpil.uk/ | Rustexp}.
411
+ *
412
+ * Each regex pattern must be 260 characters or less.
413
+ *
414
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.MemberProfile}
415
+ */
416
+ get regexPatterns() {
417
+ return this[kData].regex_patterns;
418
+ }
419
+ /**
420
+ * The internally pre-defined wordsets which will be searched for in content
421
+ *
422
+ * @see {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-preset-types | Keyword preset types}
423
+ *
424
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.KeywordPreset}
425
+ */
426
+ get presets() {
427
+ return this[kData].presets;
428
+ }
429
+ /**
430
+ * Substrings which should not trigger the rule (Maximum of 100 or 1000).
431
+ *
432
+ * Wildcard symbols can be used to customize how each keyword will be matched (see Keyword matching strategies).
433
+ *
434
+ * Each `allow_list` keyword can be a phrase which contains multiple words.
435
+ *
436
+ * Rules with `KEYWORD` triggerType accept a maximum of 100 keywords.
437
+ *
438
+ * Rules with `KEYWORD_PRESET` triggerType accept a maximum of 1000 keywords.
439
+ *
440
+ * @see {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-trigger-types | triggerType}
441
+ * @see {@link https://discord.com/developers/docs/resources/auto-moderation#auto-moderation-rule-object-keyword-matching-strategies | Keyword matching strategies}
442
+ *
443
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.Keyword}, {@link AutoModerationRuleTriggerType.KeywordPreset}, {@link AutoModerationRuleTriggerType.MemberProfile}
444
+ */
445
+ get allowList() {
446
+ return this[kData].allow_list;
447
+ }
448
+ /**
449
+ * Total number of unique role and user mentions allowed per message (Maximum of 50)
450
+ *
451
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.MentionSpam}
452
+ */
453
+ get mentionTotalLimit() {
454
+ return this[kData].mention_total_limit;
455
+ }
456
+ /**
457
+ * Whether to automatically detect mention raids
458
+ *
459
+ * Associated trigger types: {@link AutoModerationRuleTriggerType.MentionSpam}
460
+ */
461
+ get mentionRaidProtectionEnabled() {
462
+ return this[kData].mention_raid_protection_enabled;
463
+ }
464
+ };
465
+
130
466
  // src/bitfields/BitField.ts
131
467
  var BitField = class _BitField {
132
468
  static {
@@ -397,24 +733,6 @@ var PermissionsBitField = class extends BitField {
397
733
  }
398
734
  };
399
735
 
400
- // src/utils/symbols.ts
401
- var kData = /* @__PURE__ */ Symbol.for("djs.structures.data");
402
- var kClone = /* @__PURE__ */ Symbol.for("djs.structures.clone");
403
- var kPatch = /* @__PURE__ */ Symbol.for("djs.structures.patch");
404
- var kExpiresTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.expiresTimestamp");
405
- var kEndedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.endedTimestamp");
406
- var kCreatedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.createdTimestamp");
407
- var kEditedTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.editedTimestamp");
408
- var kArchiveTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.archiveTimestamp");
409
- var kStartsTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.startsTimestamp");
410
- var kEndsTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.endsTimestamp");
411
- var kAllow = /* @__PURE__ */ Symbol.for("djs.structures.allow");
412
- var kDeny = /* @__PURE__ */ Symbol.for("djs.structures.deny");
413
- var kBurstColors = /* @__PURE__ */ Symbol.for("djs.structures.burstColors");
414
- var kLastPinTimestamp = /* @__PURE__ */ Symbol.for("djs.structures.lastPinTimestamp");
415
- var kMixinConstruct = /* @__PURE__ */ Symbol.for("djs.structures.mixin.construct");
416
- var kMixinToJSON = /* @__PURE__ */ Symbol.for("djs.structures.mixin.toJSON");
417
-
418
736
  // src/channels/mixins/AppliedTagsMixin.ts
419
737
  var AppliedTagsMixin = class {
420
738
  static {
@@ -771,105 +1089,6 @@ var VoiceChannelMixin = class extends TextChannelMixin {
771
1089
  }
772
1090
  };
773
1091
 
774
- // src/Structure.ts
775
- var DataTemplatePropertyName = "DataTemplate";
776
- var OptimizeDataPropertyName = "optimizeData";
777
- var Structure = class {
778
- static {
779
- __name(this, "Structure");
780
- }
781
- /**
782
- * The template used for removing data from the raw data stored for each Structure.
783
- *
784
- * @remarks This template should be overridden in all subclasses to provide more accurate type information.
785
- * The template in the base {@link Structure} class will have no effect on most subclasses for this reason.
786
- */
787
- static DataTemplate = {};
788
- /**
789
- * @returns A cloned version of the data template, ready to create a new data object.
790
- */
791
- getDataTemplate() {
792
- return Object.create(this.constructor.DataTemplate);
793
- }
794
- /**
795
- * The raw data from the API for this structure
796
- *
797
- * @internal
798
- */
799
- [kData];
800
- /**
801
- * Creates a new structure to represent API data
802
- *
803
- * @param data - the data from the API that this structure will represent
804
- * @remarks To be made public in subclasses
805
- * @internal
806
- */
807
- constructor(data, ..._rest) {
808
- this[kData] = Object.assign(this.getDataTemplate(), data);
809
- this[kMixinConstruct]?.(data);
810
- }
811
- /**
812
- * Patches the raw data of this object in place
813
- *
814
- * @param data - the updated data from the API to patch with
815
- * @remarks To be made public in subclasses
816
- * @returns this
817
- * @internal
818
- */
819
- [kPatch](data) {
820
- this[kData] = Object.assign(this.getDataTemplate(), this[kData], data);
821
- this.optimizeData(data);
822
- return this;
823
- }
824
- /**
825
- * Creates a clone of this structure
826
- *
827
- * @returns a clone of this
828
- * @internal
829
- */
830
- [kClone](patchPayload) {
831
- const clone = this.toJSON();
832
- return new this.constructor(
833
- // Ensure the ts-expect-error only applies to the constructor call
834
- patchPayload ? Object.assign(clone, patchPayload) : clone
835
- );
836
- }
837
- /**
838
- * Function called to ensure stored raw data is in optimized formats, used in tandem with a data template
839
- *
840
- * @example created_timestamp is an ISO string, this can be stored in optimized form as a number
841
- * @param _data - the raw data received from the API to optimize
842
- * @remarks Implementation to be done in subclasses and mixins where needed.
843
- * For typescript users, mixins must use the closest ancestors access modifier.
844
- * @remarks Automatically called in Structure[kPatch] but must be called manually in the constructor
845
- * of any class implementing this method.
846
- * @remarks Additionally, when implementing, ensure to call `super._optimizeData` if any class in the super chain aside
847
- * from Structure contains an implementation.
848
- * Note: mixins do not need to call super ever as the process of mixing walks the prototype chain.
849
- * @virtual
850
- * @internal
851
- */
852
- optimizeData(_data) {
853
- }
854
- /**
855
- * Transforms this object to its JSON format with raw API data (or close to it),
856
- * automatically called by `JSON.stringify()` when this structure is stringified
857
- *
858
- * @remarks
859
- * The type of this data is determined by omissions at runtime and is only guaranteed for default omissions
860
- * @privateRemarks
861
- * When omitting properties at the library level, this must be overridden to re-add those properties
862
- */
863
- toJSON() {
864
- const data = (
865
- // Spread is way faster than structuredClone, but is shallow. So use it only if there is no nested objects
866
- Object.values(this[kData]).some((value) => typeof value === "object" && value !== null) ? structuredClone(this[kData]) : { ...this[kData] }
867
- );
868
- this[kMixinToJSON]?.(data);
869
- return data;
870
- }
871
- };
872
-
873
1092
  // src/channels/ForumTag.ts
874
1093
  var ForumTag = class extends Structure {
875
1094
  static {
@@ -4171,6 +4390,10 @@ var Connection = class extends Structure {
4171
4390
  AppliedTagsMixin,
4172
4391
  Attachment,
4173
4392
  AttachmentFlagsBitField,
4393
+ AutoModerationAction,
4394
+ AutoModerationActionMetadata,
4395
+ AutoModerationRule,
4396
+ AutoModerationRuleTriggerMetadata,
4174
4397
  AvatarDecorationData,
4175
4398
  BitField,
4176
4399
  ButtonComponent,