Skip to content

Commit

Permalink
fix(Action): Do not add the client user as a recipient (#9774)
Browse files Browse the repository at this point in the history
fix(Action): do not add the client user as a recipient

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
Jiralite and kodiakhq[bot] authored Aug 14, 2023
1 parent 727dc09 commit 24fbb11
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion packages/discord.js/src/client/actions/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,17 @@ class GenericAction {
}

getChannel(data) {
const payloadData = { recipients: data.recipients ?? [data.author ?? data.user ?? { id: data.user_id }] };
const payloadData = {};
const id = data.channel_id ?? data.id;

if ('recipients' in data) {
payloadData.recipients = data.recipients;
} else {
// 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;
Expand Down

0 comments on commit 24fbb11

Please sign in to comment.