Skip to content

Commit

Permalink
Support new audit log entry types (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khaaz authored and abalabahaha committed Nov 23, 2019
1 parent 21805a8 commit 3f87066
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
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

0 comments on commit 3f87066

Please sign in to comment.