summaryrefslogtreecommitdiff
path: root/node_modules/discord.js/src/client/actions/GuildAuditLogEntryCreate.js
blob: fa16de60b88eb91aeff135a937b100d646a210c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'use strict';

const Action = require('./Action');
const GuildAuditLogsEntry = require('../../structures/GuildAuditLogsEntry');
const Events = require('../../util/Events');

class GuildAuditLogEntryCreateAction extends Action {
  handle(data) {
    const client = this.client;
    const guild = client.guilds.cache.get(data.guild_id);
    let auditLogEntry;

    if (guild) {
      auditLogEntry = new GuildAuditLogsEntry(guild, data);

      /**
       * Emitted whenever a guild audit log entry is created.
       * @event Client#guildAuditLogEntryCreate
       * @param {GuildAuditLogsEntry} auditLogEntry The entry that was created
       * @param {Guild} guild The guild where the entry was created
       */
      client.emit(Events.GuildAuditLogEntryCreate, auditLogEntry, guild);
    }

    return { auditLogEntry };
  }
}

module.exports = GuildAuditLogEntryCreateAction;