mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
fix(thread): don't assign directly to getters (#7346)
This commit is contained in:
@@ -103,12 +103,8 @@ class ThreadChannel extends Channel {
|
|||||||
this.archiveTimestamp = Date.parse(data.thread_metadata.archive_timestamp);
|
this.archiveTimestamp = Date.parse(data.thread_metadata.archive_timestamp);
|
||||||
|
|
||||||
if ('create_timestamp' in data.thread_metadata) {
|
if ('create_timestamp' in data.thread_metadata) {
|
||||||
/**
|
// Note: this is needed because we can't assign directly to getters
|
||||||
* The timestamp when this thread was created. This isn't available for threads
|
this._createdTimestamp = Date.parse(data.thread_metadata.create_timestamp);
|
||||||
* created before 2022-01-09
|
|
||||||
* @type {?number}
|
|
||||||
*/
|
|
||||||
this.createdTimestamp = Date.parse(data.thread_metadata.create_timestamp);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.locked ??= null;
|
this.locked ??= null;
|
||||||
@@ -118,7 +114,7 @@ class ThreadChannel extends Channel {
|
|||||||
this.invitable ??= null;
|
this.invitable ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createdTimestamp ??= this.type === ChannelType.GuildPrivateThread ? super.createdTimestamp : null;
|
this._createdTimestamp ??= this.type === ChannelType.GuildPrivateThread ? super.createdTimestamp : null;
|
||||||
|
|
||||||
if ('owner_id' in data) {
|
if ('owner_id' in data) {
|
||||||
/**
|
/**
|
||||||
@@ -188,6 +184,16 @@ class ThreadChannel extends Channel {
|
|||||||
if (data.messages) for (const message of data.messages) this.messages._add(message);
|
if (data.messages) for (const message of data.messages) this.messages._add(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The timestamp when this thread was created. This isn't available for threads
|
||||||
|
* created before 2022-01-09
|
||||||
|
* @type {?number}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdTimestamp() {
|
||||||
|
return this._createdTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of associated guild member objects of this thread's members
|
* A collection of associated guild member objects of this thread's members
|
||||||
* @type {Collection<Snowflake, GuildMember>}
|
* @type {Collection<Snowflake, GuildMember>}
|
||||||
|
|||||||
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -2193,7 +2193,8 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) {
|
|||||||
public readonly archivedAt: Date | null;
|
public readonly archivedAt: Date | null;
|
||||||
public archiveTimestamp: number | null;
|
public archiveTimestamp: number | null;
|
||||||
public readonly createdAt: Date | null;
|
public readonly createdAt: Date | null;
|
||||||
public createdTimestamp: number | null;
|
private _createdTimestamp: number | null;
|
||||||
|
public readonly createdTimestamp: number | null;
|
||||||
public autoArchiveDuration: ThreadAutoArchiveDuration | null;
|
public autoArchiveDuration: ThreadAutoArchiveDuration | null;
|
||||||
public readonly editable: boolean;
|
public readonly editable: boolean;
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
|
|||||||
Reference in New Issue
Block a user