Skip to content

Commit

Permalink
fix(Action): Ensure all properties on getChannel() are passed (#10278)
Browse files Browse the repository at this point in the history
* fix(Action): ensure all properties on `getChannel()` are passed

* refactor: flip `recipient` check
  • Loading branch information
Jiralite authored May 16, 2024
1 parent 35207b0 commit 92c1a51
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions packages/discord.js/src/client/actions/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,17 @@ class GenericAction {
const payloadData = {};
const id = data.channel_id ?? data.id;

if ('recipients' in data) {
payloadData.recipients = data.recipients;
} else {
if (!('recipients' in data)) {
// Try to resolve the recipient, but do not add the client user.
const recipient = data.author ?? data.user ?? { id: data.user_id };
if (recipient.id !== this.client.user.id) payloadData.recipients = [recipient];
}

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 (
data[this.client.actions.injectedChannel] ??
this.getPayload(payloadData, this.client.channels, id, Partials.Channel)
this.getPayload({ ...data, ...payloadData }, this.client.channels, id, Partials.Channel)
);
}

Expand Down

0 comments on commit 92c1a51

Please sign in to comment.