mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
feat(Message): replace referencedMessage with fetchReference (#5577)
This commit is contained in:
@@ -442,15 +442,16 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* The Message this crosspost/reply/pin-add references, if cached
|
||||
* @type {?Message}
|
||||
* @readonly
|
||||
* Fetches the Message this crosspost/reply/pin-add references, if available to the client
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
get referencedMessage() {
|
||||
if (!this.reference) return null;
|
||||
const referenceChannel = this.client.channels.resolve(this.reference.channelID);
|
||||
if (!referenceChannel) return null;
|
||||
return referenceChannel.messages.resolve(this.reference.messageID);
|
||||
async fetchReference() {
|
||||
if (!this.reference) throw new Error('MESSAGE_REFERENCE_MISSING');
|
||||
const { channelID, messageID } = this.reference;
|
||||
const channel = this.client.channels.resolve(channelID);
|
||||
if (!channel) throw new Error('GUILD_CHANNEL_RESOLVE');
|
||||
const message = await channel.messages.fetch(messageID);
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user