mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
update GuildAuditLogs for MESSAGE_DELETE and fixed extras (#1464)
* update GuildAuditLogs for MESSAGE_DELETE and fixed extras * correct oder of targets
This commit is contained in:
@@ -9,6 +9,7 @@ const Targets = {
|
||||
INVITE: 'INVITE',
|
||||
WEBHOOK: 'WEBHOOK',
|
||||
EMOJI: 'EMOJI',
|
||||
MESSAGE: 'MESSAGE',
|
||||
};
|
||||
|
||||
const Actions = {
|
||||
@@ -83,6 +84,7 @@ class GuildAuditLogs {
|
||||
if (target < 50) return Targets.INVITE;
|
||||
if (target < 60) return Targets.WEBHOOK;
|
||||
if (target < 70) return Targets.EMOJI;
|
||||
if (target < 80) return Targets.MESSAGE;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -198,15 +200,20 @@ class GuildAuditLogsEntry {
|
||||
removed: data.options.members_removed,
|
||||
days: data.options.delete_member_days,
|
||||
};
|
||||
} else if (data.action_type === Actions.MESSAGE_DELETE) {
|
||||
this.extra = {
|
||||
count: data.options.count,
|
||||
channel: guild.channels.get(data.options.channel_id),
|
||||
};
|
||||
} else {
|
||||
switch (data.options.type) {
|
||||
case 'member':
|
||||
this.extra = guild.members.get(this.options.id);
|
||||
if (!this.extra) this.extra = { id: this.options.id };
|
||||
this.extra = guild.members.get(data.options.id);
|
||||
if (!this.extra) this.extra = { id: data.options.id };
|
||||
break;
|
||||
case 'role':
|
||||
this.extra = guild.roles.get(this.options.id);
|
||||
if (!this.extra) this.extra = { id: this.options.id, name: this.options.role_name };
|
||||
this.extra = guild.roles.get(data.options.id);
|
||||
if (!this.extra) this.extra = { id: data.options.id, name: data.options.role_name };
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -233,6 +240,8 @@ class GuildAuditLogsEntry {
|
||||
this.target = invites.find(i => i.code === (change.new || change.old));
|
||||
return this.target;
|
||||
});
|
||||
} else if (targetType === Targets.MESSAGE) {
|
||||
this.target = guild.client.users.get(data.target_id);
|
||||
} else {
|
||||
this.target = guild[`${targetType.toLowerCase()}s`].get(data.target_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user