mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 04:53:30 +01:00
feat(threadchannel): add createdTimestamp field (#7306)
Co-authored-by: Rodry <38259440+ImRodry@users.noreply.github.com> Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
@@ -101,6 +101,15 @@ class ThreadChannel extends Channel {
|
|||||||
* @type {?number}
|
* @type {?number}
|
||||||
*/
|
*/
|
||||||
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) {
|
||||||
|
/**
|
||||||
|
* The timestamp when this thread was created. This isn't available for threads
|
||||||
|
* created before 2022-01-09
|
||||||
|
* @type {?number}
|
||||||
|
*/
|
||||||
|
this.createdTimestamp = Date.parse(data.thread_metadata.create_timestamp);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.locked ??= null;
|
this.locked ??= null;
|
||||||
this.archived ??= null;
|
this.archived ??= null;
|
||||||
@@ -109,6 +118,8 @@ class ThreadChannel extends Channel {
|
|||||||
this.invitable ??= null;
|
this.invitable ??= null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.createdTimestamp ??= this.type === ChannelType.GuildPrivateThread ? super.createdTimestamp : null;
|
||||||
|
|
||||||
if ('owner_id' in data) {
|
if ('owner_id' in data) {
|
||||||
/**
|
/**
|
||||||
* The id of the member who created this thread
|
* The id of the member who created this thread
|
||||||
@@ -196,6 +207,15 @@ class ThreadChannel extends Channel {
|
|||||||
return this.archiveTimestamp && new Date(this.archiveTimestamp);
|
return this.archiveTimestamp && new Date(this.archiveTimestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time the thread was created at
|
||||||
|
* @type {?Date}
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
get createdAt() {
|
||||||
|
return this.createdTimestamp && new Date(this.createdTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The parent channel of this thread
|
* The parent channel of this thread
|
||||||
* @type {?(NewsChannel|TextChannel)}
|
* @type {?(NewsChannel|TextChannel)}
|
||||||
@@ -495,6 +515,14 @@ class ThreadChannel extends Channel {
|
|||||||
return this.archived && (this.locked ? this.manageable : this.sendable);
|
return this.archived && (this.locked ? this.manageable : this.sendable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this thread is a private thread
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
isPrivate() {
|
||||||
|
return this.type === ChannelType.GuildPrivateThread;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes this thread.
|
* Deletes this thread.
|
||||||
* @param {string} [reason] Reason for deleting this thread
|
* @param {string} [reason] Reason for deleting this thread
|
||||||
|
|||||||
14
packages/discord.js/typings/index.d.ts
vendored
14
packages/discord.js/typings/index.d.ts
vendored
@@ -512,8 +512,8 @@ export type CategoryChannelResolvable = Snowflake | CategoryChannel;
|
|||||||
|
|
||||||
export abstract class Channel extends Base {
|
export abstract class Channel extends Base {
|
||||||
public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean);
|
public constructor(client: Client, data?: RawChannelData, immediatePatch?: boolean);
|
||||||
public readonly createdAt: Date;
|
public readonly createdAt: Date | null;
|
||||||
public readonly createdTimestamp: number;
|
public readonly createdTimestamp: number | null;
|
||||||
public id: Snowflake;
|
public id: Snowflake;
|
||||||
public readonly partial: false;
|
public readonly partial: false;
|
||||||
public type: ChannelType;
|
public type: ChannelType;
|
||||||
@@ -1042,7 +1042,8 @@ export abstract class GuildChannel extends Channel {
|
|||||||
public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean);
|
public constructor(guild: Guild, data?: RawGuildChannelData, client?: Client, immediatePatch?: boolean);
|
||||||
private memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly<Permissions>;
|
private memberPermissions(member: GuildMember, checkAdmin: boolean): Readonly<Permissions>;
|
||||||
private rolePermissions(role: Role, checkAdmin: boolean): Readonly<Permissions>;
|
private rolePermissions(role: Role, checkAdmin: boolean): Readonly<Permissions>;
|
||||||
|
public readonly createdAt: Date;
|
||||||
|
public readonly createdTimestamp: number;
|
||||||
public readonly calculatedPosition: number;
|
public readonly calculatedPosition: number;
|
||||||
public readonly deletable: boolean;
|
public readonly deletable: boolean;
|
||||||
public guild: Guild;
|
public guild: Guild;
|
||||||
@@ -2169,6 +2170,8 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) {
|
|||||||
public archived: boolean | null;
|
public archived: boolean | null;
|
||||||
public readonly archivedAt: Date | null;
|
public readonly archivedAt: Date | null;
|
||||||
public archiveTimestamp: number | null;
|
public archiveTimestamp: number | null;
|
||||||
|
public readonly createdAt: Date | null;
|
||||||
|
public 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;
|
||||||
@@ -2192,6 +2195,11 @@ export class ThreadChannel extends TextBasedChannelMixin(Channel) {
|
|||||||
public rateLimitPerUser: number | null;
|
public rateLimitPerUser: number | null;
|
||||||
public type: ThreadChannelType;
|
public type: ThreadChannelType;
|
||||||
public readonly unarchivable: boolean;
|
public readonly unarchivable: boolean;
|
||||||
|
public isPrivate(): this is this & {
|
||||||
|
readonly createdTimestamp: number;
|
||||||
|
readonly createdAt: Date;
|
||||||
|
type: ChannelType.GuildPrivateThread;
|
||||||
|
};
|
||||||
public delete(reason?: string): Promise<this>;
|
public delete(reason?: string): Promise<this>;
|
||||||
public edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>;
|
public edit(data: ThreadEditData, reason?: string): Promise<ThreadChannel>;
|
||||||
public join(): Promise<ThreadChannel>;
|
public join(): Promise<ThreadChannel>;
|
||||||
|
|||||||
Reference in New Issue
Block a user