Skip to content

Commit

Permalink
fix(Message): move messageSnapshots initialization to the correct pos…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
aiko-chan-ai committed Jan 20, 2025
1 parent d5dab89 commit 9f44c85
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,29 +267,6 @@ class Message extends Base {
this.poll ??= null;
}

if (data.message_snapshots) {
/**
* The message associated with the message reference
* @type {Collection<Snowflake, Message>}
*/
this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
const channel = this.client.channels.cache.get(this.reference.channelId);
const snapshotData = {
...snapshot.message,
id: this.reference.messageId,
channel_id: this.reference.channelId,
guild_id: this.reference.guildId,
};

return coll.set(
this.reference.messageId,
channel ? channel.messages._add(snapshotData) : new this.constructor(this.client, snapshotData),
);
}, new Collection());
} else {
this.messageSnapshots ??= new Collection();
}

if ('application' in data) {
/**
* Supplemental application information for group activities
Expand Down Expand Up @@ -403,6 +380,29 @@ class Message extends Base {
this.interaction ??= null;
}

if (data.message_snapshots) {
/**
* The message associated with the message reference
* @type {Collection<Snowflake, Message>}
*/
this.messageSnapshots = data.message_snapshots.reduce((coll, snapshot) => {
const channel = this.client.channels.cache.get(this.reference.channelId);
const snapshotData = {
...snapshot.message,
id: this.reference.messageId,
channel_id: this.reference.channelId,
guild_id: this.reference.guildId,
};

return coll.set(
this.reference.messageId,
channel ? channel.messages._add(snapshotData) : new this.constructor(this.client, snapshotData),
);
}, new Collection());
} else {
this.messageSnapshots ??= new Collection();
}

/**
* A call associated with a message
* @typedef {Object} MessageCall
Expand Down

0 comments on commit 9f44c85

Please sign in to comment.