mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 21:54:46 +12:00
fix(Action): Conditionally add recipient (#9925)
fix(Action): conditionally add recipient
This commit is contained in:
parent
5dd49339ea
commit
3d5d95775b
1 changed files with 10 additions and 1 deletions
|
@ -32,8 +32,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;
|
||||
|
|
Loading…
Reference in a new issue