diff --git a/src/client/actions/MessageCreate.js b/src/client/actions/MessageCreate.js index f46aeebe9f9b..060f2a504b55 100644 --- a/src/client/actions/MessageCreate.js +++ b/src/client/actions/MessageCreate.js @@ -13,17 +13,7 @@ class MessageCreateAction extends Action { const existing = channel.messages.cache.get(data.id); if (existing) return { message: existing }; const message = channel.messages.add(data); - const user = message.author; - const member = message.member; channel.lastMessageId = data.id; - if (user) { - user.lastMessageId = data.id; - user.lastMessageChannelId = channel.id; - } - if (member) { - member.lastMessageId = data.id; - member.lastMessageChannelId = channel.id; - } /** * Emitted whenever a message is created. diff --git a/src/structures/GuildMember.js b/src/structures/GuildMember.js index b17ac86cadc2..86ce0cb05422 100644 --- a/src/structures/GuildMember.js +++ b/src/structures/GuildMember.js @@ -34,18 +34,6 @@ class GuildMember extends Base { */ this.joinedTimestamp = null; - /** - * The member's last message id, if one was sent - * @type {?Snowflake} - */ - this.lastMessageId = null; - - /** - * The id of the channel for the last message sent by the member in their guild, if one was sent - * @type {?Snowflake} - */ - this.lastMessageChannelId = null; - /** * The timestamp of when the member used their Nitro boost on the guild, if it was used * @type {?number} @@ -116,15 +104,6 @@ class GuildMember extends Base { return new GuildMemberRoleManager(this); } - /** - * The Message object of the last message sent by the member in their guild, if one was sent - * @type {?Message} - * @readonly - */ - get lastMessage() { - return this.guild.channels.resolve(this.lastMessageChannelId)?.messages.resolve(this.lastMessageId) ?? null; - } - /** * The voice state of this member * @type {VoiceState} @@ -352,8 +331,6 @@ class GuildMember extends Base { this.partial === member.partial && this.guild.id === member.guild.id && this.joinedTimestamp === member.joinedTimestamp && - this.lastMessageId === member.lastMessageId && - this.lastMessageChannelId === member.lastMessageChannelId && this.nickname === member.nickname && this.pending === member.pending && (this._roles === member._roles || @@ -377,8 +354,6 @@ class GuildMember extends Base { guild: 'guildId', user: 'userId', displayName: true, - lastMessage: false, - lastMessageId: false, roles: true, }); } diff --git a/src/structures/User.js b/src/structures/User.js index b38952c84770..ca7dae3921ed 100644 --- a/src/structures/User.js +++ b/src/structures/User.js @@ -32,18 +32,6 @@ class User extends Base { this.flags = null; - /** - * The user's last message id, if one was sent - * @type {?Snowflake} - */ - this.lastMessageId = null; - - /** - * The channel in which the last message was sent by the user, if one was sent - * @type {?Snowflake} - */ - this.lastMessageChannelId = null; - this._patch(data); } @@ -134,15 +122,6 @@ class User extends Base { return new Date(this.createdTimestamp); } - /** - * The Message object of the last message sent by the user, if one was sent - * @type {?Message} - * @readonly - */ - get lastMessage() { - return this.client.channels.resolve(this.lastMessageChannelId)?.messages.resolve(this.lastMessageId) ?? null; - } - /** * The presence of this user * @type {Presence} @@ -316,8 +295,6 @@ class User extends Base { createdTimestamp: true, defaultAvatarURL: true, tag: true, - lastMessage: false, - lastMessageId: false, }, ...props, ); diff --git a/typings/index.d.ts b/typings/index.d.ts index 4587f1031324..630bea213a3e 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -681,7 +681,6 @@ export class GuildMember extends PartialTextBasedChannel(Base) { public readonly joinedAt: Date | null; public joinedTimestamp: number | null; public readonly kickable: boolean; - public lastMessageChannelId: Snowflake | null; public readonly manageable: boolean; public nickname: string | null; public readonly partial: false; @@ -1646,7 +1645,6 @@ export class User extends PartialTextBasedChannel(Base) { public readonly dmChannel: DMChannel | null; public flags: Readonly | null; public id: Snowflake; - public lastMessageId: Snowflake | null; public readonly partial: false; public readonly presence: Presence; public system: boolean; @@ -2531,13 +2529,13 @@ export function TextBasedChannel>; export interface PartialTextBasedChannelFields { - lastMessageId: Snowflake | null; - readonly lastMessage: Message | null; send(options: string | MessagePayload | MessageOptions): Promise; } export interface TextBasedChannelFields extends PartialTextBasedChannelFields { _typing: Map; + lastMessageId: Snowflake | null; + readonly lastMessage: Message | null; lastPinTimestamp: number | null; readonly lastPinAt: Date | null; typing: boolean; diff --git a/typings/index.ts b/typings/index.ts index 7e35c5999dca..8e538d4adb87 100644 --- a/typings/index.ts +++ b/typings/index.ts @@ -1,17 +1,25 @@ import { Client, Collection, + DMChannel, + GuildMember, Intents, Message, MessageActionRow, MessageAttachment, MessageButton, MessageEmbed, + NewsChannel, Options, + PartialTextBasedChannelFields, Permissions, Serialized, ShardClientUtil, ShardingManager, + TextBasedChannelFields, + TextChannel, + ThreadChannel, + User, } from '..'; const client: Client = new Client({ @@ -455,3 +463,27 @@ assertType>(shardingManager.broadcastEval(() => 1)); assertType>(shardClientUtil.broadcastEval(() => 1)); assertType>(shardingManager.broadcastEval(async () => 1)); assertType>(shardClientUtil.broadcastEval(async () => 1)); + +declare const dmChannel: DMChannel; +declare const threadChannel: ThreadChannel; +declare const newsChannel: NewsChannel; +declare const textChannel: TextChannel; +declare const user: User; +declare const guildMember: GuildMember; + +// Test whether the structures implement send +assertType(dmChannel.send); +assertType(threadChannel); +assertType(newsChannel); +assertType(textChannel); +assertType(user); +assertType(guildMember); + +assertType(dmChannel.lastMessage); +assertType(threadChannel.lastMessage); +assertType(newsChannel.lastMessage); +assertType(textChannel.lastMessage); +// @ts-expect-error +assertType(user.lastMessage); +// @ts-expect-error +assertType(guildMember.lastMessage);