mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix guild audit log fetching of stuff (#1721)
* Update GuildAuditLogs.js * Update GuildAuditLogs.js * e
This commit is contained in:
@@ -241,18 +241,29 @@ class GuildAuditLogsEntry {
|
|||||||
* The target of this entry
|
* The target of this entry
|
||||||
* @type {Snowflake|Guild|User|Role|Emoji|Invite|Webhook}
|
* @type {Snowflake|Guild|User|Role|Emoji|Invite|Webhook}
|
||||||
*/
|
*/
|
||||||
this.target = data.target_id;
|
this.target = this.changes.reduce((o, c) => {
|
||||||
|
o[c.key] = c.new || c.old;
|
||||||
|
return o;
|
||||||
|
}, {});
|
||||||
|
this.target.id = data.target_id;
|
||||||
} else if ([Targets.USER, Targets.GUILD].includes(targetType)) {
|
} else if ([Targets.USER, Targets.GUILD].includes(targetType)) {
|
||||||
this.target = guild.client[`${targetType.toLowerCase()}s`].get(data.target_id);
|
this.target = guild.client[`${targetType.toLowerCase()}s`].get(data.target_id);
|
||||||
} else if (targetType === Targets.WEBHOOK) {
|
} else if (targetType === Targets.WEBHOOK) {
|
||||||
this.target = this.webhooks.get(data.target_id);
|
this.target = this.webhooks.get(data.target_id);
|
||||||
} else if (targetType === Targets.INVITE) {
|
} else if (targetType === Targets.INVITE) {
|
||||||
const change = this.changes.find(c => c.key === 'code');
|
if (guild.me.permissions.has('MANAGE_GUILD')) {
|
||||||
this.target = guild.fetchInvites()
|
const change = this.changes.find(c => c.key === 'code');
|
||||||
.then(invites => {
|
this.target = guild.fetchInvites()
|
||||||
this.target = invites.find(i => i.code === (change.new_value || change.old_value));
|
.then(invites => {
|
||||||
return this.target;
|
this.target = invites.find(i => i.code === (change.new || change.old));
|
||||||
});
|
return this.target;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.target = this.changes.reduce((o, c) => {
|
||||||
|
o[c.key] = c.new || c.old;
|
||||||
|
return o;
|
||||||
|
}, {});
|
||||||
|
}
|
||||||
} else if (targetType === Targets.MESSAGE) {
|
} else if (targetType === Targets.MESSAGE) {
|
||||||
this.target = guild.client.users.get(data.target_id);
|
this.target = guild.client.users.get(data.target_id);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user