fix(Action): Ensure all properties on getChannel() are passed

backport #10278 djs v14
This commit is contained in:
Elysia
2024-09-17 11:26:02 +07:00
parent f12662ef20
commit 7abf153b56

View File

@@ -35,21 +35,17 @@ class GenericAction {
const payloadData = {}; const payloadData = {};
const id = data.channel_id ?? data.id; const id = data.channel_id ?? data.id;
if ('recipients' in data) { if (!('recipients' in data)) {
payloadData.recipients = data.recipients;
} else {
// Try to resolve the recipient, but do not add the client user. // Try to resolve the recipient, but do not add the client user.
const recipient = data.author ?? data.user ?? { id: data.user_id }; const recipient = data.author ?? data.user ?? { id: data.user_id };
if (recipient.id !== this.client.user.id) payloadData.recipients = [recipient]; if (recipient.id !== this.client.user.id) payloadData.recipients = [recipient];
} }
if (id !== undefined) payloadData.id = id; if (id !== undefined) payloadData.id = id;
if ('guild_id' in data) payloadData.guild_id = data.guild_id;
if ('last_message_id' in data) payloadData.last_message_id = data.last_message_id;
return ( return (
data[this.client.actions.injectedChannel] ?? data[this.client.actions.injectedChannel] ??
this.getPayload(payloadData, this.client.channels, id, PartialTypes.CHANNEL) this.getPayload({ ...data, ...payloadData }, this.client.channels, id, PartialTypes.CHANNEL)
); );
} }