Skip to content

Commit

Permalink
update GuildAuditLogs for MESSAGE_DELETE and fixed extras (#1464)
Browse files Browse the repository at this point in the history
* update GuildAuditLogs for MESSAGE_DELETE and fixed extras

* correct oder of targets
  • Loading branch information
SpaceEEC authored and iCrawl committed May 5, 2017
1 parent 2a23941 commit 128b4ee
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/structures/GuildAuditLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Targets = {
INVITE: 'INVITE',
WEBHOOK: 'WEBHOOK',
EMOJI: 'EMOJI',
MESSAGE: 'MESSAGE',
};

const Actions = {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 128b4ee

Please sign in to comment.