feat: message structures (#10982)

* feat: message structures

* fix: docs

* chore: components and more

* feat: embed and more

* feat: more substructures and code review suggestions

* chore: tests and date conversions

* chore: jsdoc strings

* fix: tests

* fix: tests

* feat: hexColor getters

* chore: remove getters for nested data

* chore: apply suggestions from code review

* fix: burst_colors in toJSON

* docs: rephrase SectionBuilder remark

* chore: add LabelComponent

* fix: add name and size to file component

* chore: move resolved interaction data to interactions dir

* fix: code review

* chore: bump discord-api-types

* chore: apply code review suggestions

* fix: lockfile

* chore: update remark

* fix: missing export

* chore: code review and tests

* build: fix file

* fix: typo

* fix: missing toJSON

* fix: remove redundant patch overrides

* chore: missing component suffix

* chore: better name

* chore: add comment explaining timestamp conversion

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
Qjuh
2025-11-28 17:52:42 +01:00
committed by GitHub
parent aeb8986aa1
commit 19253f6b7b
79 changed files with 3281 additions and 93 deletions

View File

@@ -8,3 +8,15 @@ export function extendTemplate<SuperTemplate extends Record<string, unknown>>(
> &
SuperTemplate;
}
/**
* Turns a JavaScript Date object into the timestamp format used by Discord in payloads.
* E.g. `2025-11-16T14:09:25.239000+00:00`
*
* @private
* @param date a Date instance
* @returns an ISO8601 timestamp with microseconds precision and explicit +00:00 timezone
*/
export function dateToDiscordISOTimestamp(date: Date) {
return `${date.getUTCFullYear()}-${(date.getUTCMonth() + 1).toString().padStart(2, '0')}-${date.getUTCDate().toString().padStart(2, '0')}T${date.getUTCHours().toString().padStart(2, '0')}:${date.getUTCMinutes().toString().padStart(2, '0')}:${date.getUTCSeconds().toString().padStart(2, '0')}.${date.getUTCMilliseconds().toString().padEnd(6, '0')}+00:00`;
}

View File

@@ -2,6 +2,7 @@ export const kData = Symbol.for('djs.structures.data');
export const kClone = Symbol.for('djs.structures.clone');
export const kPatch = Symbol.for('djs.structures.patch');
export const kExpiresTimestamp = Symbol.for('djs.structures.expiresTimestamp');
export const kEndedTimestamp = Symbol.for('djs.structures.endedTimestamp');
export const kCreatedTimestamp = Symbol.for('djs.structures.createdTimestamp');
export const kEditedTimestamp = Symbol.for('djs.structures.editedTimestamp');
export const kArchiveTimestamp = Symbol.for('djs.structures.archiveTimestamp');
@@ -9,6 +10,8 @@ export const kArchiveTimestamp = Symbol.for('djs.structures.archiveTimestamp');
export const kAllow = Symbol.for('djs.structures.allow');
export const kDeny = Symbol.for('djs.structures.deny');
export const kBurstColors = Symbol.for('djs.structures.burstColors');
export const kLastPinTimestamp = Symbol.for('djs.structures.lastPinTimestamp');
export const kMixinConstruct = Symbol.for('djs.structures.mixin.construct');