From a43f3d1aebbc0d76ab2a499866f4fc7bb5e70e28 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 21 May 2024 10:32:06 +0100 Subject: [PATCH 1/4] docs(MessageReference): ? is nullable, not `undefined` --- packages/discord.js/src/structures/Message.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index 173f7edd8444..950910e8fb0a 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -361,8 +361,8 @@ class Message extends Base { * @see {@link https://discord.com/developers/docs/resources/channel#message-types} * @typedef {Object} MessageReference * @property {Snowflake} channelId The channel's id the message was referenced - * @property {?Snowflake} guildId The guild's id the message was referenced - * @property {?Snowflake} messageId The message's id that was referenced + * @property {Snowflake|undefined} guildId The guild's id the message was referenced + * @property {Snowflake|undefined} messageId The message's id that was referenced */ if ('message_reference' in data) { From 76d01cab53e0c2beb3a3cf65a6011423b70db6b1 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 21 May 2024 10:32:24 +0100 Subject: [PATCH 2/4] docs(MessageReference): sort by message type --- packages/discord.js/src/structures/Message.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index 950910e8fb0a..b73e3fb566b5 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -354,8 +354,8 @@ class Message extends Base { * Reference data sent in a message that contains ids identifying the referenced message. * This can be present in the following types of message: * * Crossposted messages (`MessageFlags.Crossposted`) - * * {@link MessageType.ChannelFollowAdd} * * {@link MessageType.ChannelPinnedMessage} + * * {@link MessageType.ChannelFollowAdd} * * {@link MessageType.Reply} * * {@link MessageType.ThreadStarterMessage} * @see {@link https://discord.com/developers/docs/resources/channel#message-types} From 07aa297f95920cbe116e45e22f1d3d2bb0561b89 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 21 May 2024 10:36:07 +0100 Subject: [PATCH 3/4] fix(Message): add throw --- packages/discord.js/src/structures/Message.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index b73e3fb566b5..fbd67e7d3309 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -708,6 +708,7 @@ class Message extends Base { async fetchReference() { if (!this.reference) throw new DiscordjsError(ErrorCodes.MessageReferenceMissing); const { channelId, messageId } = this.reference; + if (!messageId) throw new DiscordjsError(ErrorCodes.MessageReferenceMissing); const channel = this.client.channels.resolve(channelId); if (!channel) throw new DiscordjsError(ErrorCodes.GuildChannelResolve); const message = await channel.messages.fetch(messageId); From 20e038fe975da20b65c11607f12952c0417fbe8f Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Tue, 21 May 2024 10:42:41 +0100 Subject: [PATCH 4/4] docs(MessageReference): fix English --- packages/discord.js/src/structures/Message.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/Message.js b/packages/discord.js/src/structures/Message.js index fbd67e7d3309..79d6d78d7439 100644 --- a/packages/discord.js/src/structures/Message.js +++ b/packages/discord.js/src/structures/Message.js @@ -360,9 +360,9 @@ class Message extends Base { * * {@link MessageType.ThreadStarterMessage} * @see {@link https://discord.com/developers/docs/resources/channel#message-types} * @typedef {Object} MessageReference - * @property {Snowflake} channelId The channel's id the message was referenced - * @property {Snowflake|undefined} guildId The guild's id the message was referenced - * @property {Snowflake|undefined} messageId The message's id that was referenced + * @property {Snowflake} channelId The channel id that was referenced + * @property {Snowflake|undefined} guildId The guild id that was referenced + * @property {Snowflake|undefined} messageId The message id that was referenced */ if ('message_reference' in data) {