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

Adds support for new audit log events #562

Merged
merged 8 commits into from Nov 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions index.d.ts
Expand Up @@ -327,6 +327,9 @@ declare namespace Eris {
MEMBER_BAN_REMOVE: 23;
MEMBER_UPDATE: 24;
MEMBER_ROLE_UPDATE: 25;
MEMBER_MOVE: 26;
MEMBER_DISCONNECT: 27;
BOT_ADD: 28;

ROLE_CREATE: 30;
ROLE_UPDATE: 31;
Expand All @@ -345,6 +348,13 @@ declare namespace Eris {
EMOJI_DELETE: 62;

MESSAGE_DELETE: 72;
MESSAGE_BULK_DELETE: 73;
MESSAGE_PIN: 74;
MESSAGE_UNPIN: 75;

INTEGRATION_CREATE: 80;
INTEGRATION_UPDATE: 81;
INTEGRATION_DELETE: 82;
};
}

Expand Down
12 changes: 11 additions & 1 deletion lib/Constants.js
Expand Up @@ -137,6 +137,9 @@ module.exports.AuditLogActions = {
MEMBER_BAN_REMOVE: 23,
MEMBER_UPDATE: 24,
MEMBER_ROLE_UPDATE: 25,
MEMBER_MOVE: 26,
MEMBER_DISCONNECT: 27,
BOT_ADD: 28,

ROLE_CREATE: 30,
ROLE_UPDATE: 31,
Expand All @@ -154,7 +157,14 @@ module.exports.AuditLogActions = {
EMOJI_UPDATE: 61,
EMOJI_DELETE: 62,

MESSAGE_DELETE: 72
MESSAGE_DELETE: 72,
MESSAGE_BULK_DELETE: 73,
MESSAGE_PIN: 74,
MESSAGE_UNPIN: 75,

INTEGRATION_CREATE: 80,
INTEGRATION_UPDATE: 81,
INTEGRATION_DELETE: 82
};

module.exports.MessageFlags = {
Expand Down
6 changes: 6 additions & 0 deletions lib/structures/GuildAuditLogEntry.js
Expand Up @@ -2,6 +2,7 @@

const Base = require("./Base");
const Invite = require("./Invite");
const Constants = require("../Constants");

/**
* Represents a guild audit log entry describing a moderation action
Expand Down Expand Up @@ -90,6 +91,9 @@ class GuildAuditLogEntry extends Base {
} else if(this.actionType < 20) { // Channel
return this.guild && this.guild.channels.get(this.targetID);
} else if(this.actionType < 30) { // Member
if(this.actionType === Constants.AuditLogActions.MEMBER_MOVE || this.actionType === Constants.AuditLogActions.MEMBER_DISCONNECT) { // MEMBER_MOVE / MEMBER_DISCONNECT
return null;
}
return this.guild && this.guild.members.get(this.targetID);
} else if(this.actionType < 40) { // Role
return this.guild && this.guild.roles.get(this.targetID);
Expand All @@ -110,6 +114,8 @@ class GuildAuditLogEntry extends Base {
return this.guild && this.guild.emojis.find((emoji) => emoji.id === this.targetID);
} else if(this.actionType < 80) { // Message
return this.guild && this.guild.shard.client.users.get(this.targetID);
} else if(this.actionType < 90) { // Integrations
return null;
} else {
throw new Error("Unrecognized action type: " + this.actionType);
}
Expand Down