Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GuildAuditLogs for MESSAGE_DELETE and fixed extras #1464

Merged
merged 2 commits into from
May 5, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/structures/GuildAuditLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const Snowflake = require('../util/Snowflake');
const Targets = {
GUILD: 'GUILD',
CHANNEL: 'CHANNEL',
MESSAGE: 'MESSAGE',
USER: 'USER',
ROLE: 'ROLE',
INVITE: 'INVITE',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move message to the bottom so they are in order of type mod 10

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, that's the way they are sorted.

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