Skip to content

Commit

Permalink
Support stage instances in audit log
Browse files Browse the repository at this point in the history
  • Loading branch information
bsian03 committed Aug 17, 2021
1 parent 3d57bef commit 54376a0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,10 @@ declare namespace Eris {
INTEGRATION_CREATE: 80;
INTEGRATION_UPDATE: 81;
INTEGRATION_DELETE: 82;

STAGE_INSTANCE_CREATE: 83;
STAGE_INSTANCE_UPDATE: 84;
STAGE_INSTANCE_DELETE: 85;
};
ChannelTypes: {
GUILD_TEXT: 0;
Expand Down
6 changes: 5 additions & 1 deletion lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ module.exports.AuditLogActions = {

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

STAGE_INSTANCE_CREATE: 83,
STAGE_INSTANCE_UPDATE: 84,
STAGE_INSTANCE_DELETE: 85
};

module.exports.MessageActivityTypes = {
Expand Down
12 changes: 9 additions & 3 deletions lib/structures/GuildAuditLogEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const {AuditLogActions} = require("../Constants");
* For example, if a channel was renamed from #general to #potato, this would be `{name: "potato"}``
* @prop {Object?} before The properties of the targeted object before the action was taken
* For example, if a channel was renamed from #general to #potato, this would be `{name: "general"}``
* @prop {(CategoryChannel | TextChannel | VoiceChannel)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE) and 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) only
* @prop {(CategoryChannel | TextChannel | VoiceChannel | NewsThreadChannel | PrivateThreadChannel | PublicThreadChannel)?} channel The channel targeted in the entry, action types 26 (MEMBER_MOVE), 72/74/75 (MESSAGE_DELETE/PIN/UNPIN) and 83/84/85 (STAGE_INSTANCE_CREATE/UPDATE/DELETE) only
* @prop {Number?} count The number of entities targeted
* For example, for action type 26 (MEMBER_MOVE), this is the number of members that were moved/disconnected from the voice channel
* @prop {Number?} deleteMemberDays The number of days of inactivity to prune for, action type 21 (MEMBER_PRUNE) only
Expand Down Expand Up @@ -66,7 +66,11 @@ class GuildAuditLogEntry extends Base {
this.count = +data.options.count;
}
if(data.options.channel_id) {
this.channel = guild.channels.get(data.options.channel_id);
if(this.actionType >= 83) {
this.channel = guild.threads.get(data.options.channel_id);
} else {
this.channel = guild.channels.get(data.options.channel_id);
}
if(data.options.message_id) {
this.message = this.channel && this.channel.messages.get(data.options.message_id) || {id: data.options.message_id};
}
Expand Down Expand Up @@ -119,8 +123,10 @@ 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
} else if(this.actionType < 83) { // Integrations
return null;
} else if(this.actionType < 90) { // Stage Instances
return this.guild && this.guild.threads.get(this.targetID);
} else {
throw new Error("Unrecognized action type: " + this.actionType);
}
Expand Down

0 comments on commit 54376a0

Please sign in to comment.